in reply to Re: argmin & argmax
in thread argmin & argmax

use Sort::Key::Top;
my $max = topsort 1, @list; my $min = topsort -1, @list;

Replies are listed 'Best First'.
Re^3: argmin & argmax
by ikegami (Patriarch) on May 13, 2025 at 04:45 UTC

    Nice ...or is it? Seeing as it returns the top x values, is the algorithm used O(n) as desired, or O(n log n) like a sort? That said, the extra log n doesn't add much, though.