PrimitiveArraySorter { public static void merge(short[] array, short[] mergeArray, int pivotIndex, ShortComparator comparator) { merge(array, mergeArray, pivotIndex, array.length, comparator); } private  PrimitiveArraySorter(); static void sort(short[] array, ShortComparator comparator); static void sort(short[] array, int fromIndex, int toIndex, ShortComparator comparator); static boolean sortAndMerge(short[] array, short[] mergeArray, int pivotIndex, int toIndex, ShortComparator comparator); static void merge(short[] array, short[] mergeArray, int pivotIndex, ShortComparator comparator); static void merge(short[] array, short[] mergeArray, int pivotIndex, int toIndex, ShortComparator comparator);  }
@Test public void test_merging_simple_array() { short[] array = {-20, -12, 2, -22, -11, 33, 44}; short[] expected = {-22, -20, -12, -11, 2, 33, 44}; short[] result = new short[array.length]; PrimitiveArraySorter.merge(array, result, 3, Short::compare); assertArrayEquals(expected, result); }