-最近在學習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