MergeSort { private static void sort(Comparable[] a, Comparable[] aux, int lo, int hi) { if (hi <= lo) return; int mid = lo + (hi - lo) / 2; sort(a, aux, lo, mid); sort(a, aux, mid + 1, hi); merge(a, aux, lo, mid, hi); } private  MergeSort(); static void sort(Comparable[] a); static int[] indexSort(Comparable[] a); static void main(String[] args);  }
@Test public void sortString() { String sortStr = "abc def cfh"; String[] sortArray = sortStr.split(" "); MergeSort.sort(sortArray); String resultStr = "abc cfh def"; String[] resultArray = resultStr.split(" "); assertEquals("111",sortArray,resultArray); }
@Test public void sortInteger() { Integer[] sortIntegerArray = {9,2,3,4}; MergeSort.sort(sortIntegerArray); Integer[] resultArray = {2,3,4,9}; Assert.assertArrayEquals(sortIntegerArray, resultArray); }