快排序
def QuickSort(nums, low, high):
if low >= high:
return
pos = FindPos(nums, low, high)
QuickSort(nums, low, pos-1)
QuickSort(nums, pos+1, high)
return nums
def FindPos(nums, low, high):
val = nums[low]
while low < high:
while low < high and nums[high] >= val:
high -= 1
nums[low] = nums[high]
while low < high and nums[low] <= val:
low += 1
nums[high] = nums[low]
nums[low] = val
return low