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