Skip to content

Instantly share code, notes, and snippets.

@rayjcwu
Created March 21, 2014 22:27
Show Gist options
  • Select an option

  • Save rayjcwu/9697779 to your computer and use it in GitHub Desktop.

Select an option

Save rayjcwu/9697779 to your computer and use it in GitHub Desktop.
sort(Integer[] A, Comparator <Integer>() {
@Override
public int compare(Integer a, Integer b) {
final boolean aEven = (a % 2) == 0;
final boolean bEven = (b % 2) == 0;
if ((aEven && bEven )|| (!aEven && !bEven)) {
return a - b;
} else {
return (aEven)? -1: 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment