def sort(A):
    if len(A) < 2:
        return A
    p = A[0]
    print(p,A[1:]) 
    X, Y = divide(p,A[1:])
    print(X,p,Y)
    print()
    return sort(X) + [p] + sort(Y)

def divide(p, A):
    if len(A) < 1:
        return ([], [])
    X, Y = divide(p, A[1:])
    a = A[0]
    if a < p:
        return ([a] + X, Y)
    else:
        return (X, [a] + Y)
