首页 > 代码库 > python快速排序

python快速排序

技术分享
 1 def quicksort(array):
 2     less, greater = [], []
 3    if len(array)<=1:
 4         return array
 5    elem = array.pop()
 6    for i in array:
 7        if i <= elem:
 8             less.append(i)
 9        else: greater.append(i)
10    return quicksort(less) + [elem] + quicksort(greater)
View Code

 

python快速排序