How to sort based on/compare multiple values in Kotlin?
Kotlin’s stdlib offers a number of useful helper methods for this. First, you can define a comparator using the compareBy() method and pass it to the sortedWith() extension method to receive a sorted copy of the list: val list: List<Foo> = … val sortedList = list.sortedWith(compareBy({ it.a }, { it.b }, { it.c })) Second, … Read more