Perl Monk, Perl Meditation | |
PerlMonks |
Re^2: How can one find five max values and five min values with positions in descending and ascending order from arrays?by tobyink (Canon) |
on Apr 26, 2013 at 09:09 UTC ( [id://1030795]=note: print w/replies, xml ) | Need Help?? |
Indeed, linear selection is significantly faster (O(n)) than sorting for large lists of values. I'll take this opportunity to plug Sort::Key::Top::PP, my pure Perl implementation of some of the ideas in Sort::Key::Top. It uses a lot of trickery and some ugly looking code to provide very fast results. (Much faster that code you might write yourself if you were caring about its aesthetics.)
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
In Section
Seekers of Perl Wisdom
|
|