Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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