python 实现快速排序


def quick_sort(arr):
    if len(arr) <= 1:
        return arr
    tmp = quick_sort([lt for lt in arr[1:] if lt < arr[0]]) + [arr[0]] + quick_sort([ge for ge in arr[1:] if ge >= arr[0]])
    return tmp
 
if __name__ == '__main__':
    li = [5, 4, 8, 7, 3, 1, 10, 6, 2, 9]
 
    li = quick_sort(li)
 
    print li
点赞