list=[50,0,10,30]
using recursive function find min to max in ascending order.
lst=[50,0,10,30]
def sort(lst):
if len(lst) == 0:
return lst
pivot = lst[0]
pivots = [x for x in lst if x == pivot]
small = sort([x for x in lst if x < pivot])
large = sort([x for x in lst if x > pivot])
return small + pivots + large
sort(lst)
Comments
Leave a comment