def partition(lst, start, end):
    """
    move elements below pivot value to left half of list and bigger to right half
    return the new position of the pivot element
    """
    # use pivot as the last element in list
    # get it value
    x = lst[end]
    # initial store_index
    store_index = start
    # loop up to pivot (last element)
    i = start
    for i in range(start, end):
        # if current value below pivot
        if lst[i] <= x:
            # swap index and store_index elements if are differ
            if i != store_index:
                lst[i], lst[store_index] = lst[store_index], lst[i]
            # update store_index
            store_index += 1
    # swap pivot element (last in list) and store_index
    lst[store_index], lst[i + 1] = lst[i + 1], lst[store_index]
    return store_index