return i - 1

def quicksort(array, start=0, end=None):
    if end is None:
        end = len(array) - 1
if end - start < 1:
    return
idx_pivot = random.randint(start, end)
i = sub_partition(array, start, end, idx_pivot)
quicksort(array, start, i - 1)
quicksort(array, i + 1, end)
In-place QuickSort in Python