Skip to content

Instantly share code, notes, and snippets.

@iyengarajay
Created May 21, 2016 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iyengarajay/99099dbbe9c6519050f050eba0886ead to your computer and use it in GitHub Desktop.
Save iyengarajay/99099dbbe9c6519050f050eba0886ead to your computer and use it in GitHub Desktop.
public class TeenageSorter implements Comparator<Teenager>{
@Override
public int compare(Teenager t1, Teenager t2)
{
if( t1.getAge() == t2.getAge())
{
return (t1.getPhoneBrand().compareTo(t2.getPhoneBrand()));
}
return t1.getAge() > t2.getAge()? 1 : -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment