Skip to content

Instantly share code, notes, and snippets.

@chingovan
Created July 11, 2015 19:06
Show Gist options
  • Select an option

  • Save chingovan/6730dc7a6e1df0b0361f to your computer and use it in GitHub Desktop.

Select an option

Save chingovan/6730dc7a6e1df0b0361f to your computer and use it in GitHub Desktop.
a = [3, 6, 9, 2, 6, 8, 9, 1, 7, 21, 7, 12]
for i in range(1, len(a)):
t = a[i];
index = i;
for j in range(i -1, -1, -1):
if a[j] > t:
a[j + 1] = a[j]
index = j
else:
break
if index != i:
a[index] = t;
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment