def insert(x, li):
if not len(li): return [x]
hd, *tl = li
if x < hd: return [x, *li]
return [hd, *insert(x, tl)]
def isort(li):
if not len(li): return []
hd, *tl = li
return insert(hd, isort(tl))
unsorted = [4,2,5,1,3]
sorted = isort(unsorted)
print(unsorted)
print(sorted)
To embed this project on your website, copy the following code and paste it into your website's HTML: