python data structure quick sort

<python data structure quick sort>

1.  [Code] If combined with a random function, the effect will be better 

def quicksort(lst):
    if lst:
        l=lst.pop()
        x=[]
        y=[]
        while lst:
            m=lst.pop()
            if m>l:
                x.append(m)
            else:
                y.append(m)
        if x:
            quicksort(x)
            lst.extend(x)
        lst.append(l)
        if y:
            quicksort(y)
            lst.extend(y)
    return lst

Guess you like

Origin blog.csdn.net/lmrylll/article/details/132008248