We break down how to work with collection grouping in Kotlin using
groupBy: why the result is
Map<K, List<T>>, how to read groups safely (by iterating and by key using
?:), how to normalize keys (
trim()/
lowercase()), and how to use the overload
groupBy(keySelector, valueTransform) to store only the needed data inside groups.