如果a1-a2大于0,返回正数是升序;如果a2-a1小于0,返回负数是降序
//如果a1-a2大于0,返回正数是升序;如果a2-a1小于0,返回负数是降序
Collections.sort(students, new Comparator(){
public int compare(Student a1, Student a2) {
int x = a1.getAge() - a2.getAge();
int y = a1.getSalary() - a2.getSalary();
int z = a1.getHeight() - a2.getHeight();
if(x==0){
if(y==0){
return z;
}
return y;
}
return x;
}
});