快速排序
def qsort(array): if len(array)<2: return array else: pivot = array[0] less=[i for i in array[1:] if i <=pivot] greater = [i for i in array[1:] if i > pivo return qsort(less) +[pivot]+qsort(greater)
In [4]: print(qsort([5,4,6,3,2,0,1]))
[0, 1, 2, 3, 4, 5, 6]