-
-
Save iyengarajay/99099dbbe9c6519050f050eba0886ead to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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