groupBy method

List<List<E>> groupBy(
  1. T selector(
    1. E el
    )
)

Implementation

List<List<E>> groupBy(T Function(E el) selector) {
  Map<T, List<E>> map = {};
  for (E el in this) {
    if (map[selector(el)] == null) {
      map[selector(el)] = [el];
      continue;
    }
    map[selector(el)]!.add(el);
  }
  return map.entries.map((el) => el.value).toList();
}