def partition(array, low, high):
    """
    Returns the index of the sorted pivot (which is the array indexed at the high index), 
    with everything prior in the list being less then pivot and everything after being greater then pivot.
    """
    pivot = array[high]

    i = low - 1

    for j in range(low, high):
        if array[j] <= pivot:
            i += 1

            temp = array[j]
            array[j] = array[i]
            array[i] = temp

    temp = array[high]
    array[high] = array[i + 1]
    array[i + 1] = temp
    return i + 1