I have a list of Object say Car. First I want to group the collection on some field say carCompanyId
. So I will have something like,
Map<Integer, List<Car>> = cars.stream().collect(Collectors.groupingBy(Car::getCarCompanyId))
I want every list in above Map to be sorted by one of the fields. Can I achieve this by adding parameter to grouping by function so that it sorts the list while grouping it.