Java 8’s enhancements to the Comparator
interface make it a lot more elegant:
public static final Comparator<Student> BY_NAME = Comparator.comparing(Student::getName);
public static final Comparator<Student> BY_Gpa = Comparator.comparingInt(Student::getGpa);
solved Comparator in Java [closed]