Skip to content

Instantly share code, notes, and snippets.

@prasadwrites
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save prasadwrites/7c54177187358e369f44 to your computer and use it in GitHub Desktop.

Select an option

Save prasadwrites/7c54177187358e369f44 to your computer and use it in GitHub Desktop.
InsertionSort in Python
def insertionsort(arr):
for i in range(1,len(arr)):
temp = arr[i]
k = i
while k>0 and temp < arr[k-1] :
arr[k] = arr[k-1]
k-=1
arr[k] = temp
a = [999,45,343,3,34,556,233,645,2335,34,454]
print(a)
insertionsort(a)
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment