Skip to content

Instantly share code, notes, and snippets.

@sujayy1983
Created January 25, 2015 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sujayy1983/1121631c227b4315179f to your computer and use it in GitHub Desktop.
Save sujayy1983/1121631c227b4315179f to your computer and use it in GitHub Desktop.
Implementaion of insertion sort.
"""
@Author: Sujayyendhiren Ramarao Srinivasamurthi
@Description: Insertion sort
"""
def insertion_sort( data ):
length = len(data)
for idx in range(1, length):
val = data[idx]
while idx > 0 and val < data[idx-1]:
data[idx] = data[idx-1]
idx = idx -1;
data[idx] = val
return data
data = [10,5,8,900,100,25,6,1,0,53,500]
print insertion_sort( data )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment