groupBy<K> method

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

Group by method for Lists. Example usage: List list.groupBy((a) => a.date);

Implementation

Map<K, List<E>> groupBy<K>(K Function(E) keyFunction) => fold(
      <K, List<E>>{},
      (Map<K, List<E>> map, E element) =>
          map..putIfAbsent(keyFunction(element), () => <E>[]).add(element),
    );