def _partition(array, low, high):
    """Choose the first element of `array`, put to the left of it
    all elements which are smaller, and to the right all elements which
    are bigger than it.

    Return the final position of this element.
    """
    if low >= high:
        return

    i = low + 1
    j = high
    while i <= j:
        if array[i] <= array[low]:
            i += 1
        else:
            array[i], array[j] = array[j], array[i]
            j -= 1

    array[low], array[j] = array[j], array[low]
    return j