попробуйте это
Map<RamiBean, Map<String, Map<String, List<AllertaBean>>>> complexMap = allerte.stream()
.distinct()
.collect(Collectors.groupingBy(
ab -> ab.getRamoBean(),
Collectors.groupingBy(ab -> ab.getPuntoBean().getNomePunto(),
Collectors.toMap(
AllertaBean::getDescAllerta,
ab -> new ArrayList(Arrays.asList(ab)),
(abList1, abList2) -> {
abList1.addAll(abList2);
abList1.sort(Comparator.comparing(ab -> ab.getPuntoBean().getKm()))
return abList1;
}
)
)
));
или это
Map<RamiBean, Map<String, Map<String, List<AllertaBean>>>> complexMap = allerte.stream()
.distinct()
.collect(Collectors.groupingBy(
ab -> ab.getRamoBean(),
Collectors.groupingBy(ab -> ab.getPuntoBean().getNomePunto(),
Collectors.groupingBy(AllertaBean::getDescAllerta,
Collectors. collectingAndThen(Collectors.toList(),
abList -> abList.sort(Comparator.comparing(ab -> ab.getPuntoBean().getKm()))
))));