Ayfri
01/27/2022, 1:19 PM[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 alsoMichael de Kaste
01/27/2022, 2:04 PMnumbers.groupingBy { it }.eachCount().map { (k, v) -> v to k }.sortedByDescending { it.first }
Ayfri
01/27/2022, 7:18 PM