Let's say I have the following code:
val list = mutableListOf("abab", "abcd", "aaa")
list.sortBy { it.length } //result: [aaa, abab, abcd]
This sorts the list by the lengths of the Strings.
How do I break draws (2 Strings of the same length) by some other rule, lets say number of appearance of the char 'a'. This way, one would have a hirarchy of comparison-rules: First length, then break draws by number of 'a', then maybe some other rule.
The function sortBy only receives a selector, which maps the elements to a comparable value, which is not capable for what I want to do I think.