• + 0 comments
    public class Solution {
        public static void main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
            try (BufferedReader bIn = new BufferedReader(new InputStreamReader(System.in))) {
                String line = bIn.readLine();
                List<Player> scoreList = new ArrayList<>();
                while ((line = bIn.readLine()) != null) {
                    scoreList.add(new Player(line));
                }
                ScoreCompare cp = new ScoreCompare();
                scoreList.stream().sorted(cp::compare).forEach(elem -> System.out.println(elem.getName() + " " + elem.getScore()));
            } catch (Exception e) {
                //
            }
        }
        
        public static class Player {
            private String name;
            private int score;
            
            public Player(String text) {
                String[] strArray = text.split(" ");
                this.name = strArray[0];
                this.score = Integer.valueOf(strArray[1]).intValue();
            }
            
            public String getName() {
                return this.name;
            }
            
            public void setName(String name) {
                this.name = name;
            }
            
            public int getScore() {
                return this.score;
            }
            
            public void setName(int score) {
                this.score = score;
            }
        }
        
        public static class ScoreCompare implements Comparator<Player> {
            @Override
            public int compare(Player p1, Player p2) {
                if (p1.getScore() < p2.getScore()) {
                    return 1;
                } else if (p1.getScore() > p2.getScore()) {
                    return -1;
                } else {
                    return p1.getName().compareTo(p2.getName());
                }
            }
        }
    }