compare integers java sort

Solutions on MaxInterview for compare integers java sort by the best coders in the world

showing results for - "compare integers java sort"
Jona
12 May 2016
1public class AgeComparatorDesc implements Comparator<Student> {
2
3  @Override
4  public int compare(Student o1, Student o2) {
5    if (o1.age > o2.age) {
6        return -1;
7    } else if (o1.age < o2.age) {
8        return 1;
9    }    
10     return 0;
11  }
12
13}