def func(lt=[]):
if len(lt)<=1:
return lt
key = lt[0]
lt_l=[]
lt_r=[]
lt_m=[]
for i in lt:
if i<key:
lt_l.append(i)
elif i>key:
lt_r.append(i)
else:
lt_m.append(i)
lt_l=func(lt_l)
lt_r=func(lt_r)
return lt_l+lt_m+lt_r
lt=[12, 34, 2, 5, 8, 1, 9]
print (func(lt))
def func(lt=[]):
if type(lt).__name__!='list' and type(lt).__name__!='tuple':
return lt
if type(lt).__name__=='tuple':
lt=list(lt)
if len(lt)<=1:
return lt
else:
for i in range(1,len(lt)):
for j in range(len(lt)-i):
if lt[j]>lt[j+1]:
lt[j],lt[j+1]=lt[j+1],lt[j]
return lt
lt=[32,12,3,27,6,9,1]
tp=(2,6,1,9,4)
print (func(lt))
print (func(tp))