Skip to content

Instantly share code, notes, and snippets.

@SharpMan
Created July 28, 2015 18:06
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 SharpMan/7a19ae630212c8ed34fa to your computer and use it in GitHub Desktop.
Save SharpMan/7a19ae630212c8ed34fa to your computer and use it in GitHub Desktop.
public static <T> Comparator<T> Compose(
final Comparator<? super T> primary,
final Comparator<? super T> secondary
) {
return (T a, T b) -> {
int result = primary.compare(a, b);
return result == 0 ? secondary.compare(a, b) : result;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment