Autumn 2013CE203 Part 428 The Collections Class 4 class DOBComp implements Comparator { public int compare(Person p1, Person p2) { int x = p1.dateOfBirth().compareTo (p2.dateOfBirth()); if (x!=0) return x; else return p1.compareTo(p2); // must not return 0 if different people // have same date of birth } } …… Collections.sort(personList, new DOBComp());
{}