Hi, I have a list of numbers, and I want to sort by descending this list by the number of time it appears in the list and group it by Pair<number of time it appears, value>
Example :
[5, 5, 2, 2, 2, 1, 8, 3, 3, 3, 3]
I want to sort it to
[(4, 3), (3, 2), (2, 5), (1, 1), (8, 8)]
, I do not care about sorting by value
For now I have this
numbers.groupingBy { it }.eachCount().toList().sortedByDescending { it.second }
And it's working but I'm asking if there is a simple way, I do not care about speed also