groupBy<K> method

Map<K, List<E>> groupBy<K>(
  1. K f(
    1. E value
    )
)

groupBy extension for List Grock GroupBy

Implementation

Map<K, List<E>> groupBy<K>(K Function(E value) f) {
  final map = <K, List<E>>{};
  for (final element in this) {
    final key = f(element);
    map.putIfAbsent(key, () => <E>[]).add(element);
  }
  return map;
}