Python-快速排序算法
-最近在学习python,写了一个快速排序的算法,分享给大家。
#array's quick sort
def quickSort(arr,i,j):
if i < j:
base = quick(arr, i, j)
quickSort(arr, i, base)
quickSort(arr, base+1, j)
def quick(arr, i, j):
base = arr[i]
while i < j:
while i < j and arr[j] > base:
j-=1
while i < j and arr[j] < base:
arr[i] = arr[j]
i+=1
arr[j] = arr[i]
arr[i] = base
return i