Hic kasmaya gerek yok. Custom sort ile nLogN de cozulur, memory complexity O( n ) olur in-place sort yapilirsa. Performans super onemliyse O ( n ) le de cozulebilir tek iterasyonda.
public static void main(String[] args) { Integer[] nums = new Integer[]{15, 10, 1, 5, 7, 8, 54, 32, 67, 89, 4, 7, 9, 12, 44}; Arrays.sort(nums, (i1, i2) -> { if (i1 % 2 == 0 && i2 % 2 == 0) { return 0; } return i1 % 2 == 0 ? -1 : 1; }); }Edit ( Aciklama ): Custom comparator ile cift sayilara oncelik verirsin.