Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import abstractClasses.Car;
- import classes.PerformanceCar;
- import classes.ShowCar;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.ArrayList;
- import java.util.LinkedHashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- public class Main {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- Map<String, Integer> personPoints = new LinkedHashMap<>();
- personPoints.put("Gosho", 100);
- personPoints.put("Tosho", 23);
- personPoints.put("Sasho", 1);
- personPoints.put("Pesho", 5);
- personPoints.put("Esho", 5);
- reader.close();
- personPoints = personPoints.entrySet().stream().sorted((x1, x2) -> {
- return x2.getValue().compareTo(x1.getValue());
- }).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
- //result of personPoints:
- //"Pesho" -> "5"
- //"Sasho" -> "1"
- //"Esho" -> "5"
- //"Tosho" -> "23"
- //"Gosho" -> "100"
- }
- }
Add Comment
Please, Sign In to add comment