in reply to *Fastest* way to print a hash sorted by value

The fatest way would be to print them to /dev/null.

More seriously, there are basically two options, sort the entries, and take the first $N value of the sorted list. Or go through the hash once, and keep track of the top $N entries. The latter approach means you do fewer comparisons, the former approach mean you do less work in Perl, and more in C. Which one will be faster depends on the size of your hash, $N, and the amount of core memory available to your process.

Abigail

  • Comment on Re: *Fastest* way to print a hash sorted by value