kotlin.text.groupBy
groupBy
inline fun <K> CharSequence.groupBy( keySelector: (Char) -> K ): Map<K, List<Char>>
Groups characters of the original char sequence by the key returned by the given keySelector function applied to each character and returns a map where each group key is associated with a list of corresponding characters.
The returned map preserves the entry iteration order of the keys produced from the original char sequence.