def quicksort(array):
less = []
greater = []
if len(array) <= 1:
return array
pivot = array.pop()
for x in array:
if x <= pivot:
less.append(x)
else:
greater.append(x)
return quicksort(less) + [pivot]+quicksort(greater)
if __name__ == '__main__':
print(quicksort([1, 3, 5, 2, 4, 85, 65]))
输出:
标签:greater,less,Python,quicksort,array,排序,快速 From: https://www.cnblogs.com/xxxyz/p/16596082.html