Collections.sort(list, (p1, p2) -> {
int ret = Integer.compare(p1.getId(), p2.getId());
if (ret == 0) {
ret = p1.getName().compareTo(p2.getName();
}
if (ret == 0) {
ret = Integer.compare(p1.getAge(), p2.getAge());
}
return ret;
});
Collections.sort(list, new Comparator<Person>(){
@Override
public int compare(Person p1, Person p2) {
int ret = p1.getId() - p2.getId();
if (ret == 0) {
ret = p1.getName().compareTo(p2.getName());
}
if (ret == 0) {
ret = p1.getAge() - p2.getAge();
}
return ret;
}
});