def partition(seq, left, right, pivot_index):
    """
    Reorders the slice with values lower than the pivot at the left side,
    and values bigger than it at the right side.
    Also returns the store index.

    :param seq: A list of integers
    :param left: An integer representing left index
    :param right: An integer representing left index
    :param pivot_index: An integer that we're pivoting off
    :rtype: An stored_index integer
    """
    pivot_value = seq[pivot_index]
    seq[pivot_index], seq[right] = seq[right], seq[pivot_index]
    store_index = left
    for i in range(left, right):
        if seq[i] < pivot_value:
            seq[i], seq[store_index] = seq[store_index], seq[i]
            store_index += 1
    seq[store_index], seq[right] = seq[right], seq[store_index]
    return store_index