fork(3) download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. Integer[] arr = new Integer[]{54,23,545,65,23,4,1,2,5};
  9. Arrays.sort(arr, new Comparator<Integer>(){public int compare(Integer o1, Integer o2) {return o1%2 == o2%2 ? o1.compareTo(o2) : (o1%2 == 0 ? -1 : 1); }});
  10. System.out.println(Arrays.toString(arr));
  11. }
  12. }
Success #stdin #stdout 0.07s 381184KB
stdin
Standard input is empty
stdout
[2, 4, 54, 1, 5, 23, 23, 65, 545]