def merge_sorted(lst,  func=cmp, reversed=False):
    """
    >>> l = [2,3,1,0,6,4,7,8,5,9]
    >>> merge_sorted(l)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    >>> merge_sorted(l, func=lambda a, b: cmp(b, a))
    [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
    >>> merge_sorted(l, reversed=True)
    [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
    >>> merge_sorted(l, func=lambda a, b: cmp(b, a), reversed=True)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    """
    assert isinstance(lst, list)
    if len(lst) <= 1:
        return lst

    def merge(a, b):
        mlst = []
        while a and b:
            mlst.append(a.pop(0) if func(a[0], b[0]) < 0 else b.pop(0))
        return mlst + a + b
    m = int(len(lst) / 2)
    a = merge_sorted(lst[:m], func=func)
    b = merge_sorted(lst[m:], func=func)
    l = merge(a, b)
    return l[::-1] if reversed else l
def merge_sorted ( lst , func = cmp , reversed = False ) : assert isinstance ( lst , list ) if len ( lst ) <= 1 : return lst def merge ( a , b ) : mlst = [ ] while a and b : mlst . append ( a . pop ( 0 ) if func ( a [ 0 ] , b [ 0 ] ) < 0 else b . pop ( 0 ) ) return mlst + a + b m = int ( len ( lst ) / 2 ) a = merge_sorted ( lst [ : m ] , func = func ) b = merge_sorted ( lst [ m : ] , func = func ) l = merge ( a , b ) return l [ : : - 1 ] if reversed else l
>>> l = [2,3,1,0,6,4,7,8,5,9]
    >>> merge_sorted(l)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    >>> merge_sorted(l, func=lambda a, b: cmp(b, a))
    [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
    >>> merge_sorted(l, reversed=True)
    [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
    >>> merge_sorted(l, func=lambda a, b: cmp(b, a), reversed=True)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]