in reply to Re: How can one find five max values and five min values with positions in descending and ascending order from arrays?
in thread How can one find five max values and five min values with positions in descending and ascending order from arrays?
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.)
|
|---|