def sortList(alist):
alen = len(alist)
if alen == 0:
return alist
if alen > 0:
aitem = alist[alen / 2]
aleftlist = []
arightlist = []
for i in range(0,alen):
afirstitem = alist[i]
if i <> alen / 2:
if afirstitem > aitem:
arightlist.append(afirstitem)
else:
aleftlist.append(afirstitem)
aleftlist = sortList(aleftlist)
arightlist = sortList(arightlist)
aleftlist.append(aitem)
return aleftlist + arightlist
alist = [0,1,2]
print(sortList(alist))