Comparable bakes a single sort order into the class. But what if you want to sort students by name in one place and by GPA in another? That's where Comparator<T> comes in.
A Comparator is a separate object that defines a compare(T a, T b) method. You pass it to Collections.sort() as a second argument.
Comparator<Student> byName = new Comparator<Student>() {
public int compare(Student a, Student b) {
return a.name.compareTo(b.name);
}
};
Collections.sort(students, byName);
This keeps sorting logic outside the class, so you can define as many sort orders as you need without modifying Student itself.