def tri_fusion(l):
    if len(l) == 1:
        return l
    else:
        return fusion(tri_fusion(l[:len(l)//2]), tri_fusion(l[len(l)//2:]))

def fusion(l1, l2):
    i1, i2 = 0, 0
    l = []
    while i1 < len(l1) or i2 < len(l2):
        if i1 < len(l1) and i2 < len(l2) and l1[i1] < l2[i2]:
            l.append(l1[i1])
            i1 += 1
        elif i1 < len(l1) and i2 < len(l2) and l1[i1] > l2[i2]:
            l.append(l2[i2])
            i2 += 1
        elif i1 >= len(l1):
            l.append(l2[i2])
            i2 += 1
        else:
            l.append(l1[i1])
            i1 += 1
    return l

tri_fusion([9, 3, 4, 2, 1, 6, 5, 7, 8])
