Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
C - insertion sort
def insertion_sort(n):
if len(n) == 1:
return n
b = insertion_sort(n[1:])
m = len(b)
for i in range(m):
if n[0] <= b[i]:
return b[:i]+[n[0]]+b[i:]
return b + [n[0]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment