kmongo / kotlin.collections / com.mongodb.client.MongoIterable / groupBy

groupBy

inline fun <T, K> MongoIterable<T>.groupBy(crossinline keySelector: (T) -> K): Map<K, List<T>> (source)

Groups elements of the original collection by the key returned by the given keySelector function applied to each element and returns a map where each group key is associated with a list of corresponding elements.

The returned map preserves the entry iteration order of the keys produced from the original collection.

//Unresolved: samples.collections.Collections.Transformations.groupBy
inline fun <T, K, V> MongoIterable<T>.groupBy(crossinline keySelector: (T) -> K, crossinline valueTransform: (T) -> V): Map<K, List<V>> (source)

Groups values returned by the valueTransform function applied to each element of the original collection by the key returned by the given keySelector function applied to the element and returns a map where each group key is associated with a list of corresponding values.

The returned map preserves the entry iteration order of the keys produced from the original collection.

//Unresolved: samples.collections.Collections.Transformations.groupByKeysAndValues