in reply to Better mousetrap (getting top N values from list X)
Just as an aside, if you had lazy lists (coming in perl6) and the appropriate sort, the following should run in optimal O(X*log(N)) time, straight out of the box.
-- All code is 100% tested and functional unless otherwise noted.
@topN = (sort @X)[0..($N-1)];
-- All code is 100% tested and functional unless otherwise noted.
In Section
Seekers of Perl Wisdom