Python中经典快速排序算法的实现

def quicksort(arr):
    if len(arr)<= 1:
        return arr
    pivot = arr[len(arr)//2]
    left = [x for x in arr if x pivot]
    return quicksort(left) + middle +quicksort(right)

list1 = [3,6,8,10,1,2,1]
a = quicksort(list1)
print(a)

 

你可能感兴趣的:(数据库)