def k(a):
    if type(a).__name__=="list":
        if len(a) <= 1:
            return a
        mid = len(a) // 2
        B=k(a[:mid])
        C=k(a[mid:])
        if len(B) == len(C) == 1:
            b=B[-1]
            c=C[-1]
            if c<b:
                return [c,b]
            else:
                return [b,c]
        else:
            return (k(B) + k(C)) if (k(B) < k(C)) else (k(C) + k(B)) 
def p(a):
    return [k(a)[0]]+k(k(a)[1:])
print(k(p([1,1,4,5,14,1,9,19,8,10])))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: