static void Sort2(int[] values, int start, int end) { //if (start >= end) // return; int pivotIndex = (start + end) / 2; int pivotValue = values[pivotIndex]; int temp = values[pivotIndex]; values[pivotIndex] = values[end]; values[end] = temp; int storeIndex = start; for (int i = start; i < end; i++) { if (values[i] < pivotValue) { temp = values[i]; values[i] = values[storeIndex]; values[storeIndex] = temp; storeIndex += 1; } } temp = values[storeIndex]; values[storeIndex] = values[end]; values[end] = temp; if (start + 16 > storeIndex) { InsertionSort.Sort_InPlace(values, start, storeIndex); } else { Sort2(values, start, storeIndex - 1); } if (storeIndex + 16 > end) { InsertionSort.Sort_InPlace(values, storeIndex + 1, end + 1); } else { Sort2(values, storeIndex + 1, end); } }