### Question:
Sorting { public static int partitionIndices( final int[] indices, final int k0, final int left0, final int right0, final IntComparator comp) { int k = k0; int left = left0; int right = right0; for (;;) { int idx = selectPivotIndex(indices, left, right, comp); int pivotIndex = partition(indices, left, right, idx, comp); if (left + k - 1 == pivotIndex) { int i = right0; while (i > pivotIndex) { if (comp.compare(indices[i], indices[pivotIndex]) == 0) { pivotIndex++; if (i > pivotIndex) { swap(indices, i, pivotIndex); } } else { i--; } } return pivotIndex; } if (left + k - 1 < pivotIndex) { right = pivotIndex - 1; } else { k -= (pivotIndex - left + 1); left = pivotIndex + 1; } } } private  Sorting(); static int selectPivotIndex(final int[] indices, 
        int left, 
        int right, 
        final IntComparator comp); static int partitionIndices(
            final int[] indices,
            final int k0,
            final int left0,
            final int right0,
            final IntComparator comp); static void quickSort(final IndexedSortable sortable); static void quickSort(final IndexedSortable sortable, final int offset, final int len); static void quickSort(final int[] arr, final IntComparator comp); static void quickSort(final int[] arr, final int offset, final int len, final IntComparator comp); static int medianOf3(final int[] a, final int x, final int y, final int z, final IntComparator c); static int medianOf3(IndexedSortable sortable, int x, int y, int z); static void parallelSort(double[] dValues, int[] iValues);  }### Answer:
@Test public void testPartitionIndices() { Random random = new Random(); final int count = 50 + random.nextInt(100); final int[] values = new int[count]; for (int i = 0; i < count; i++) { values[i] = random.nextInt(10); } int m = 1 + (count - 1 + 0) / 2; int pi = Sorting.partitionIndices(values, m, 0, count - 1, new SimpleIntComparator()); checkPartitionIndex(values, pi); }