Given the following class (simplified for the question):
public static class Match {
private final String type;
private fina
Try to use a TreeMap for this :
UPDATE
List matchStream1 = matchStream.
collect(Collectors.groupingBy(Match::getType,
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Match::getScore)))))
.values()
.stream()
.map(TreeSet::last)
.collect(Collectors.toList());
In case your Match class implements Comparable. You can simplify this:
() -> new TreeSet<>(Comparator.comparing(Match::getScore))
to this:
TreeSet::new