Skip to content

Instantly share code, notes, and snippets.

@iyengarajay
Created May 22, 2016 06:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save iyengarajay/93bdda98c7a946f19d1fd72f1930d1d4 to your computer and use it in GitHub Desktop.
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