//Time Complexity O(n log n)
void quickSort(int *arr, int l, int r) {
int i = l;
int j = r;
int pivot = arr[(l + r) / 2];
while (i <= j) {
while (arr[i] < pivot) i++;
while (arr[j] > pivot) j--;
if (i <= j) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i++;
j--;
}
}
if (l < j) quickSort(arr, l, j);
if (i < r) quickSort(arr, i, r);
}
int items[] = {4, 1, 5, 3, 2};
quickSort(items, 0, 4);
//items is {1, 2, 3, 4, 5}