标签:ret else def 快速排序 sort quick python return gre
def quicksort(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>pivot]
return quicksort(less)+[pivot]+quicksort(greater)
print quicksort([10,5,2,3])
标签:ret else def 快速排序 sort quick python return gre
原文地址:https://www.cnblogs.com/Jmmm/p/10617420.html