I'm fine with the names of min(count:)
, max(count:)
, and their unconstrained min(count:by:)
and max(count:by:)
counterparts.
I agree with others that sortedPrefix
is ambiguous. I always thought the ambiguity is easily solved by realising the unintended meaning makes no sense to exist as a function of its own. But that's ambiguity anyway.
I think the only slight downside with the min
/max
naming (and which sortedPrefix
, or sortedSuffix
for the matter wouldn't suffer) is it's not perfectly clear from their name in what order the result will be. Especially for max(count:[by:])
, why doesn't its return value contain elements in descending order like "the greatest N" commonly*)? Or should it?
But this is easily documented I think.
*) E.g. In Python, heapq.nlargest(3, [8, 4, 6, 2, 3, 5, 1, 7])
returns [8, 7, 6]
, not [6, 7, 8]
.