@Test public void test() { Merging.Sort(CommonData.OUT_OF_ORDER_ARRAY); for (int a : CommonData.OUT_OF_ORDER_ARRAY) { System.out.println(a); } }
public static void Sort(int[] array) { if (array.length > 1) { int length1 = array.length / 2; int[] array1 = new int[length1]; System.arraycopy(array, 0, array1, 0, length1); Sort(array1); int length2 = array.length - length1; int[] array2 = new int[length2]; System.arraycopy(array, length1, array2, 0, length2); Sort(array2); int[] result = Merge(array1, array2); System.arraycopy(result, 0, array, 0, array.length); } }
Merging { public static void Sort(int[] array) { if (array.length > 1) { int length1 = array.length / 2; int[] array1 = new int[length1]; System.arraycopy(array, 0, array1, 0, length1); Sort(array1); int length2 = array.length - length1; int[] array2 = new int[length2]; System.arraycopy(array, length1, array2, 0, length2); Sort(array2); int[] result = Merge(array1, array2); System.arraycopy(result, 0, array, 0, array.length); } } }
Merging { public static void Sort(int[] array) { if (array.length > 1) { int length1 = array.length / 2; int[] array1 = new int[length1]; System.arraycopy(array, 0, array1, 0, length1); Sort(array1); int length2 = array.length - length1; int[] array2 = new int[length2]; System.arraycopy(array, length1, array2, 0, length2); Sort(array2); int[] result = Merge(array1, array2); System.arraycopy(result, 0, array, 0, array.length); } }  }
Merging { public static void Sort(int[] array) { if (array.length > 1) { int length1 = array.length / 2; int[] array1 = new int[length1]; System.arraycopy(array, 0, array1, 0, length1); Sort(array1); int length2 = array.length - length1; int[] array2 = new int[length2]; System.arraycopy(array, length1, array2, 0, length2); Sort(array2); int[] result = Merge(array1, array2); System.arraycopy(result, 0, array, 0, array.length); } }  static void Sort(int[] array); }
Merging { public static void Sort(int[] array) { if (array.length > 1) { int length1 = array.length / 2; int[] array1 = new int[length1]; System.arraycopy(array, 0, array1, 0, length1); Sort(array1); int length2 = array.length - length1; int[] array2 = new int[length2]; System.arraycopy(array, length1, array2, 0, length2); Sort(array2); int[] result = Merge(array1, array2); System.arraycopy(result, 0, array, 0, array.length); } }  static void Sort(int[] array);  }