Reputation: 5496
As simple sorting by two values in Kotlin can be like this:
.sortedWith(compareBy({ it.lastName }, { it.firstName }))
How to sort by those 2 field and adding case insensitive order? I know that this can be only applied to sorting by one field:
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, { it.lastName })
How to do this for both fields?
Upvotes: 1
Views: 1598
Reputation: 12953
Not like this?
.sortedWith(compareBy({ it.lastName.toLowerCase() }, { it.firstName.toLowerCase() }))
Upvotes: 3