- 时间复杂度O(nlogN)
- 不稳定排序
def quick_sort(arr, low, high):
if low < high:
m = partition(arr, low, high)
quick_sort(arr, low, m)
quick_sort(arr, m+1, high)
def partition(arr, left, right):
priv = arr[left]
while left < right:
while left < right and arr[right] > priv:
right -= 1
arr[left] = arr[right]
while left < right and arr[left] >= priv:
left += 1
arr[right] = arr[left]
arr[left] = priv
return left