box-o-sand/insertion_sort01.py
2011-08-15 06:47:22 -04:00

9 lines
201 B
Python

def insertion_sort(a):
for j in range(1, len(a)):
key = a[j]
i = j - 1
while i >= 0 and a[i] > key:
a[i + 1] = a[i]
i = i - 1
a[i + 1] = key