groupBy<G> method

Map<G, List<T>> groupBy<G>(
  1. G grouper(
    1. T e
    )
)

Implementation

Map<G, List<T>> groupBy<G>(G Function(T e) grouper) {
  var groups = <G, List<T>>{};

  for (var e in this) {
    var g = grouper(e);
    var list = groups.putIfAbsent(g, () => <T>[]);
    list.add(e);
  }

  return groups;
}