标签:快速 turn 排序 ret data sort int and while
def quick_sort(data, left, right):
if left < right:
mid = partition(data, left, right)
quick_sort(data, left, mid - 1)
quick_sort(data, mid + 1, right)
def partition(data, left, right):
tmp = data[left]
while left < right:
while left < right and data[right] > tmp:
right = right - 1
data[left] = data[right]
while left < right and data[left] < tmp:
left = left + 1
data[right] = data[left]
data[left] = tmp
return left
li = [32, 29, 14, 37, 20]
quick_sort(li, 0, 4)
print(li)
标签:快速 turn 排序 ret data sort int and while
原文地址:https://www.cnblogs.com/qiaoqianshitou/p/9928199.html