guys, how can I perform complex sort on the collec...
# getting-started
e
guys, how can I perform complex sort on the collection, like this one in sql:
Copy code
ORDER BY name ASC, age DESC
? I tried something like this, but second sort function completely override previous order
Copy code
persons.sortedBy { it.name }.sortedByDescending { it.age }
k
evkaky:
listOf<Person>().sortedWith(compareBy<Person> { it.name }.thenByDescending { it.age })
👍 1
e
Can I set descending order in this example:
Copy code
list.sortedWith(compareBy({ it.a }, { it.b }, { it.c }))
?
in one of the lambdas
k
I don't think so
e
thank you dude
k
you're welcome