mostCommon

fun mostCommon(n: Int = Int.MAX_VALUE): List<Pair<T, Int>>

Returns up to n elements with their counts, highest count first.

Ties keep first-insertion order. Runs in time proportional to the number of distinct elements times its logarithm.

Throws