python三行代码实现快速排序
def quick_sort(array): if len(array) < 2: return array return quick_sort([lt for lt in array[1:] if lt < array[0]]) + [array[0]] + quick_sort([ge for ge in array[1:] if ge >= array[0]])
def quick_sort(array): if len(array) < 2: return array return quick_sort([lt for lt in array[1:] if lt < array[0]]) + [array[0]] + quick_sort([ge for ge in array[1:] if ge >= array[0]]) arr = [3, 1, 6, 8, 2, 2, 3] res = quick_sort(arr) print(res)