public class Student implements Comparable { public String name; public int ID; public Student( int id, String n) { ID = id; name = n; } public int compareTo(Student other) { return this.ID - other.ID ; //return this.name.compareTo(other.name); } } public class StudentSortByName implements Comparator { public int compare(Student o1, Student o2) { return o1.name.compareTo(o2.name); } }