Skip to content

Instantly share code, notes, and snippets.

@chirag-shinde
Created June 27, 2020 09:42
Show Gist options
  • Save chirag-shinde/fbf5df47ab21a6552d46f5e1078d23d8 to your computer and use it in GitHub Desktop.
Save chirag-shinde/fbf5df47ab21a6552d46f5e1078d23d8 to your computer and use it in GitHub Desktop.
def insertion_sort(list: [int]) -> [int]:
for i in range(1, len(list)):
element = list[i]
j = i - 1
while j >= 0 and element < list[j]:
list[j + 1] = list[j]
j -= 1
list[j + 1] = element
return list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment