Files
30-seconds-of-code/test/insertion_sort/insertion_sort.py
2018-04-14 10:54:46 +00:00

9 lines
216 B
Python

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