Algorithms / Sorting

//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[] = {41532};
quickSort(items, 04);
//items is {1, 2, 3, 4, 5}