How to sort ArrayList using Comparator? [duplicate]
问题 This question already has answers here : Sort ArrayList of custom Objects by property (25 answers) Closed 5 years ago . I have a Class Student that Implements a static method public static Comparator<Student> getCompByName() that returns a new comparator object for Student that compares 2 Students objects by the attribute 'name'. I need to now test this by sorting a students ArrayList by 'name' using my function getCompByName(). Here is my Comparator method in my Student class. public static