Python 的快速排序
Sunday, 25. June 2006, 15:21:09
import random
def quicksort(lst):
if len(lst) <= 1: return lst
pivot = lst[random.randrange(len(lst))]
left = [x for x in lst if x < pivot]
middle = [x for x in lst if x == pivot]
right = [x for x in lst if x > pivot]
return quicksort(left) + middle + quicksort(right)




How to use Quote function: