def partition(alist, first, last):
    """
    Partition alist into smaller and larger values.

    Returns pivot position.