快速排序 python版

 
def qsort(data, l, r):
    if l < r:
        # 取左边的数作为分界点
        tmp = data[l]
        lt = l
        rt = r
        while lt < rt:
            # 找右边比tmp小的数
            while data[rt] >= tmp and rt > lt:
                rt -= 1
            data[lt] = data[rt]
            # 找左边比tmp大的数
            while data[lt] <= tmp and lt < rt:
                lt += 1
            data[rt] = data[lt]
	
        data[lt] = tmp
        qsort(data, l, lt-1)
        qsort(data, lt+1, r)
    else:
        return
点赞