def mSrt(ls): if len(ls)<=1: return ls print(ls) hf=len(ls)//2 return mMrg(mSrt(ls[0:hf]),mSrt(ls[hf:])) def mMrg(l1,l2): if len(l1)<=0: return l2 elif len(l2) <=0: return l1 elif l1[0]>l2[0]: return l1[0:1]+mMrg(l1[1:],l2) else: return l2[0:1]+mMrg(l1,l2[1:]) import random a=list(map(lambda x:random.randint(1,200),range(20))) mSrt(a)