This groups the elements into a Key-Value Map. The Key is the result of the selector function, and the value is the list of all the elements that satisfy the selector function condition:
val strings = listOf("abc", "ade", "bce", "bef")
val groupped = strings.groupBy { s -> s[0] }
We grouped here by the first character of the string, and now the grouped map looks like this [“a” : [“abc”, “ade”], “b” : [“bce”, “bef”].