CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
partial sort

 



Jakob
stranger

May 3, 2001, 6:47 AM

Post #1 of 4 (447 views)
partial sort Can't Post

Hi,

Is there an easy and fast way to a partial sort on a hash (by the values)?

In this case the hash is very long and only the first 100 elements are of interest, so sorting the entire hash is not an option.

Is there a standard function or a module from CPAN that does the trick?

Ciao,
Jakob



geest
Deleted

May 3, 2001, 10:37 AM

Post #2 of 4 (444 views)
Re: partial sort [In reply to] Can't Post

Take a look at Tie::IxHash
I suppose you will find what you're looking for



Jakob
stranger

May 4, 2001, 2:45 AM

Post #3 of 4 (433 views)
Re: partial sort [In reply to] Can't Post

Tie::IxHash does not seem to be what I am looking for. It preserves the order of the hash, but in my case the elements are added in a random order.
Afterwards I need only the 100 elements with the highest values.



japhy
Enthusiast

May 4, 2001, 4:50 AM

Post #4 of 4 (431 views)
Re: partial sort [In reply to] Can't Post

It sounds like you want to use a heap structure. There are heap modules on CPAN as well.

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives