package hackerrank.ctci;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/ctci-comparator-sorting
 */
public class Comparator {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // TODO
    }
}

@@ -19,16 +19,41 @@
 .ctci;%0A%0A
+import java.util.Arrays;%0A
 import j
@@ -170,16 +170,531 @@
 rator %7B%0A
+    private static class Checker implements java.util.Comparator%3CPlayer%3E %7B%0A        @Override%0A        public int compare(Player o1, Player o2) %7B%0A            if (o1.score == o2.score) %7B%0A                return o1.name.compareTo(o2.name);%0A            %7D%0A            return Integer.compare(o2.score, o1.score);%0A        %7D%0A    %7D%0A%0A    private static class Player%7B%0A        String name;%0A        int score;%0A%0A        Player(String name, int score)%7B%0A            this.name = name;%0A            this.score = score;%0A        %7D%0A    %7D%0A%0A
     publ
@@ -746,17 +746,19 @@
 Scanner 
-i
+sca
 n = new 
@@ -789,15 +789,424 @@
     
-// TODO
+int n = scan.nextInt();%0A%0A        Player%5B%5D player = new Player%5Bn%5D;%0A        Checker checker = new Checker();%0A%0A        for (int i = 0; i %3C n; i++) %7B%0A            player%5Bi%5D = new Player(scan.next(), scan.nextInt());%0A        %7D%0A        scan.close();%0A%0A        Arrays.sort(player, checker);%0A        for (int i = 0; i %3C player.length; i++) %7B%0A            System.out.printf(%22%25s %25s%5Cn%22, player%5Bi%5D.name, player%5Bi%5D.score);%0A        %7D
 %0A   

Solve Comparator