Skip to content

Instantly share code, notes, and snippets.

@dragstar328
Created April 21, 2015 09:37
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 dragstar328/d3fd60736e2f049b1126 to your computer and use it in GitHub Desktop.
Save dragstar328/d3fd60736e2f049b1126 to your computer and use it in GitHub Desktop.
アルゴリズムクイックリファレンス:挿入ソート
def insertion_sort(target):
for i in range(len(target)):
insert(target, i, target[i])
def insert(target, pos, value):
i = pos - 1
while (i >= 0 and target[i] > value):
target[i + 1] = target[i]
i = i - 1
target[i + 1] = value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment