SortUtil { public static void mergeSort(int[] data) { if (data == null || data.length < 2) { return; } int[] temp = new int[data.length]; int mid = (data.length - 1) / 2; mergeSort(data, 0, mid, temp); mergeSort(data, mid + 1, data.length - 1, temp); mergeArray(data, 0, mid, data.length - 1, temp); }  static void setIsPrint(boolean isPrint); static int[] initArray(final int n); static void print(int[] data); static void selectSort(int[] data); static void insertSort(int[] data); static void binaryInsertionSort(int[] data); static void shellSort(int[] data); static void bubbleSort(int[] data); static void quickSort(int[] data); static void mergeSort(int[] data); static void heapSort(int[] data); static void radixSort(int[] data, int maxBit); static int getDigitBit(int data); static int getFigure(int data, int n); List<SortObject<Double>> multiSort(int num, boolean ascend);  }
@Test public void testMergeSort() { int[] origin = SortUtil.initArray(arraySize); SortUtil.print(origin); long start = System.currentTimeMillis(); SortUtil.mergeSort(origin); long interval = System.currentTimeMillis() - start; System.out.println("call mergeSort, time cost is: " + interval + "ms"); SortUtil.print(origin); }