def qsort(array): if len(array) <= 1: return array pivot=array.pop() leftarray = [i for i in array if i < pivot] rightarray = [i for i in array if i >= pivot] return qsort(leftarray)+[pivot]+qsort(rightarray) a = [1,2,7,321,46323,213,1] print(qsort(a))
递归写法很好理解
栈的实现
标签:排序,return,qsort,pivot,array,rightarray,快速 From: https://www.cnblogs.com/xiaoruirui/p/16814738.html