【Python】快速排序

def myquicksort(a,h,t):
    if h>=t:
        return
    b=a[h]
    i=h
    j=t
    while i!=j:
        while a[j]>=b and j>i:
            j-=1
        while a[i]<=b and ii:
            a[i],a[j]=a[j],a[i]
    a[h]=a[i]
    a[i]=b
    myquicksort(a,h,i-1)
    myquicksort(a,i+1,t)
a=[6,10,16,3,8,23,15,7,2,11]
print(f'Original:{a}.')
myquicksort(a,0,len(a)-1)
print(f'Sorted:{a}')

你可能感兴趣的:(python,开发语言)