Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Comparator<Teenager> phoneBrandPossibleNulls =
Comparator.comparing(Teenager::getPhoneBrand,Comparator.nullsLast(Comparator.naturalOrder()));
Collections.sort(teens, Comparator.comparing(Teenager::getAge)
.thenComparing(phoneBrandPossibleNulls));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment