def _in_place_partition(a, start, end):
    count = 0
    pivot = randint(start, end)
    temp = a[end]
    a[end] = a[pivot]
    a[pivot] = temp
    new_pivot_index = start - 1
    for index in range(start, end):
        count += 1
        if a[index] < a[end]:  # check if current val is less than pivot value
            new_pivot_index = new_pivot_index + 1
            temp = a[new_pivot_index]
            a[new_pivot_index] = a[index]
            a[index] = temp

    temp = a[new_pivot_index + 1]
    a[new_pivot_index + 1] = a[end]
    a[end] = temp
    return new_pivot_index + 1, count