def insert(x, li):
  match li:
    case []: return [x]
    case [hd, *tl]:
      if x < hd: return [x, *li]
      return [hd, *insert(x, tl)]

def isort(li):
  match li:
    case []: return []
    case [hd, *tl]: 
      return insert(hd, isort(tl))
    
unsorted = [4,2,5,1,3]
sorted = isort(unsorted)
print(unsorted)
print(sorted)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: