Last active
March 31, 2024 07:40
-
-
Save madken/0a09b03be3af7b25c963ed585e29a7bc to your computer and use it in GitHub Desktop.
kotlin sort a list of pairs by second and then first value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun sortListOfPairDesc(list: List<Pair<String, Int>>): List<Pair<String, Int>> { | |
return list.sortedWith(compareBy({ it.second }, { it.first })).asReversed() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
also sort with first/second value then by second/first value in 2d IntArrays :>