in reply to Re: argmin & argmaxin thread argmin & argmax
my $max = topsort 1, @list; my $min = topsort -1, @list; [download]
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.