@@ -0,0 +1,1535 @@
+import java.util.*;%0A%0Aclass Student implements Comparable%3CStudent%3E %7B%0A    private int id;%0A    private String fname;%0A    private double cgpa;%0A    public Student(int id, String fname, double cgpa) %7B%0A        super();%0A        this.id = id;%0A        this.fname = fname;%0A        this.cgpa = cgpa;%0A    %7D%0A    public int getId() %7B%0A        return id;%0A    %7D%0A    public String getFname() %7B%0A        return fname;%0A    %7D%0A    public double getCgpa() %7B%0A        return cgpa;%0A    %7D%0A%0A    public int compareTo(Student other) %7B%0A        if (Double.compare(other.getCgpa(), this.getCgpa()) != 0) %7B%0A            return Double.compare(other.getCgpa(), this.getCgpa());%0A        %7D else if (this.getFname().compareTo(other.getFname()) != 0) %7B%0A            return this.getFname().compareTo(other.getFname());%0A        %7D else %7B%0A            return Integer.compare(other.getId(), this.getId());%0A        %7D%0A    %7D%0A%7D%0A%0Apublic class Solution %7B%0A    public static void main(String%5B%5D args)%7B%0A        Scanner in = new Scanner(System.in);%0A        int testCases = Integer.parseInt(in.nextLine());%0A%0A        List%3CStudent%3E studentList = new ArrayList%3CStudent%3E();%0A        while(testCases%3E0)%7B%0A            int id = in.nextInt();%0A            String fname = in.next();%0A            double cgpa = in.nextDouble();%0A%0A            Student st = new Student(id, fname, cgpa);%0A            studentList.add(st);%0A%0A            testCases--;%0A        %7D%0A        in.close();%0A%0A        studentList.sort(null);%0A          for(Student st: studentList)%7B%0A            System.out.println(st.getFname());%0A        %7D%0A    %7D%0A%7D%0A

Solve java sort