Answer to Question #299771 in Python for Michael

Question #299771

list=[50,0,10,30]

using recursive function find min to max in ascending order.


1
Expert's answer
2022-02-19T06:22:06-0500
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS