Commit 906d49b1 by xmh

只要最高分

1 parent 9b0e1ff7
......@@ -269,7 +269,9 @@ public class PersonService {
matchResultSize = size;
}
Stream<Person> stream = matchResult.stream().sorted(Comparator.comparingDouble(Person::getScore).reversed());
Map<String, Person> collect = matchResult.stream().collect(Collectors.toMap(Person::getPersonId, x -> x, (a, b) -> a.getScore() >= b.getScore() ? a : b));
Stream<Person> stream = collect.values().stream().sorted(Comparator.comparingDouble(Person::getScore).reversed());
if (matchResult.size() > matchResultSize) {
stream = stream.limit(matchResultSize);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!