countBy

inline fun <T, K> Iterable<T>.countBy(selector: (T) -> K): Map<K, Int>

Returns a map of each distinct value of selector to the number of elements producing it.

Keys are ordered by first occurrence. An empty receiver yields an empty map.