算法-排序(二)-快速排序
python
def quickSort(list,low,high): point = list[low] l = low h = high while l < h:#注:一定要从右开始遍历 while(l<h) & (list[h]>=point): h -= 1 while(l<h) & (list[l]<=point): l += 1 if(l<h): temp = list[l] list[l] = list[h] list[h]= temp list[low] = list[l] list[l] = point if(l+1<high): quickSort(list, l+1, high) if(low<l-1): quickSort(list, low, l-1) list = [7,5,2,3,6,1] print quickSort(list,0,len(list)-1) print list #[1,2,3,5,6,7]