Sorting hashes...by fiddler42 (Beadle)
|on May 10, 2007 at 18:50 UTC||Need Help??|
fiddler42 has asked for the wisdom of the Perl Monks concerning the following question:
Kind, Gentle Folk,
I have a need to sort a bunch of geometric boxes in two ways, and I'm not sure how to do it in perl efficiently. Here are the starting conditions of this problem:-
1. I have a text string (the name of a box)
2. I have the lower left coordinates of a box
3. I have the upper right coordinates of a box
4. I have the area of a box
I have several million overlapping boxes within the area of one large, master box. Here is what I need to do:-
1. Sort all of the areas, from largest to smallest
2. Once the sort completes, I need the N largest boxes that do not overlap at all.
I am not looking for a detailed solution, just a rough idea on the best approach. Can someone help fill in these blanks?
Again, I'm just looking for some guidance here. The numerical sort of the hash probably won't be that tough, but identifying the N largest, non-overlapping boxes has me stumped at the moment!