快排:用中间mid把左右两边分开,左边是比mid小,右边比mid大,接着递归
def quick_sort(a,first,last):
if first>=last:
return
low=first
high=last
middle_value=a[low]
n=len(a)
while low<high:
while low<high and middle_value<=a[high]:
high-=1
a[low]=a[high]
while low<high and middle_value>a[low]:
low+=1
a[high]=a[low]
a[low]=middle_value
quick_sort(a,first,low-1)
quick_sort(a,low+1,last)
a=[10,2,4,9,6,11]
quick_sort(a,0,5)
print(a)