Once your class implements Comparable, sorting is line of code. Both Collections.sort() and Arrays.sort() rely on the compareTo method you defined.
List<Student> students = new ArrayList<>();
students.add(new Student("Alice", 3.8));
students.add(new Student("Bob", 3.5));
students.add(new Student("Carol", 3.9));
Collections.sort(students);
// Order: Bob (3.5), Alice (3.8), Carol (3.9)
The sort is ascending by default because your compareTo returns a negative value when this.gpa is smaller. To sort descending, reverse the comparison: Double.compare(other.gpa, this.gpa). Keep in mind that compareTo should be consistent with equals. If objects are equal according to equals, compareTo should return .