Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Collections.sort(teens,new Comparator<Teenager>() {
@Override
public int compare(Teenager t1, Teenager t2)
{
return
ComparisonChain.start()
.compare(t1.getAge(), t2.getAge())
.compare(t1.getPhoneBrand(), t2.getPhoneBrand(),Ordering.natural().nullsLast())
.result();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment