-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
ood-interview/tic_tac_toe/tictactoe/ScoreTracker.java
Lines 26 to 32 in bce98e5
| public Map<Player, Integer> getTopPlayers() { | |
| return playerRatings.entrySet() | |
| .stream() | |
| .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) | |
| .map(Map.Entry::getKey) | |
| .collect(Collectors.toMap(player -> player, player -> playerRatings.get(player))); | |
| } |
Inside the method, it sorts the players by their ratings in descending order, then collects them into a map. As it returns HashMap, the sorted order is not preserved. I think it should collect players into a list, so it can keep the sorted order. What do you think?
Metadata
Metadata
Assignees
Labels
No labels