Sorting algorithms/Insertion sort: Difference between revisions

Line 2,783:
j -= 1
l[j+1] = key</lang>
 
Using pythonic iterators:
 
<lang python>def insertion_sort_iter(L):
for i, value in enumerate(L):
for j in range(i - 1, -1, -1):
if L[j] > value:
L[j + 1] = L[j]
L[j] = value</lang>
===Insertion sort with binary search===
<lang python>def insertion_sort_bin(seq):
Anonymous user