int partition(int *arr, int left, int right) {
int pivot = arr[left];
while (left < right) {
while (left < right && arr[right] > pivot) {
--right;
}
arr[left] = arr[right];
while (left < right && arr[left] <= pivot) {
++left;
}
arr[right] = arr[left];
}
arr[left] = pivot;
return left;
}
void qsort(int *arr, int left, int right) {
int pos;
if (left < right) {
pos = partition(arr, left, right);
qsort(arr, left, pos - 1);
qsort(arr, pos + 1, right);
}
}