Let's say I have a list of lines in Kotlin: stringList: MutableList<String>
Then it is easy to sort such a list in case of an insensitive order by doing this:
stringList.sortWith(String.CASE_INSENSITIVE_ORDER)
But how would I sort the list of objects in case of an insensitive order? For example:places: MutableList<Place>
Where Placeis a simple class with 2 fields - name: Stringand id: Int, and I would like to sort these places in the field name.
I tried to do something like this: places.sortedWith(compareBy { it.name })but this solution is not case sensitive.
source
share