快速排序算法

快速排序算法python实现

defsub_sort(list,low,high):

provider=list[low]

while(low<high):

whilelow<highandlist[high]>provider:

high=high-1

list[low],list[high]=list[high],list[low]

whilelow<highandlist[low]<provider:

low=low+1

list[low],list[high]=list[high],list[low]

returnlow

defq_sort(list,low,high):

iflow<high:

index=sub_sort(list,low,high)

q_sort(list,low,index)

q_sort(list,index+1,high)

相关推荐