def _in_place_quick_sort(a, start, end):
    count = 0
    if start < end:
        pivot = randint(start, end)
        temp = a[end]
        a[end] = a[pivot]
        a[pivot] = temp

        p, count = _in_place_partition(a, start, end)
        count += _in_place_quick_sort(a, start, p - 1)
        count += _in_place_quick_sort(a, p + 1, end)
    return count