groupingBy()는
이렇게 3가지를 인자로 받을 수 있다.
// 분류 기준으로만 하면 자동으로 Map<{keyType}, List<{valueType}>> 형식으로 aggregate 된다.
List<Person> aList = List.of(Person.of("name", "female"));
Map<String, List<Person>> personGroupByName = aList.stream().collect(groupingBy(Person::getName));
// 다른 type로 aggregate도 가능하다.
List<Person> aList = List.of(Person.of("name", "female"));
Map<String, List<Person>> personGroupByName = aList.stream().collect(groupingBy(Person::getName), TreeMap::new);
Comparator를 잘 이용하면, 여러개의 predicate로 sort가 가능하다.
Comparator<Person> compare = Comparator.comparingLong(Person::getAge)
.thenComparing(Comparator.comparing(Person::getBrith).reversed());
List<Person> sorted = aList.stream().sorted(compare).collect(toList());