def qsort(list,low,high):
i,j = low,high
if i>=j:
return
k = list[i]
while i!=j:
# 从右往左 比k小的数字扔到左边
while j>i and list[j] >= k:
j-=1;
list[i] = list[j]
# 从左往右 比k大的数字扔到右边
while i<j and list[i] <= k:
i+=1
list[j] = list[i]
# 还原中心点的k , 并以中心点分组, 两边继续开始排序
list[i] = k
qsort(list,low,i-1)
qsort(list,i+1,high)
s=[4,3,2,5,2,4]
qsort(s,0,5)
print(s)
转载于:https://my.oschina.net/tasker/blog/815802