Sorting algorithms/Insertion sort: Difference between revisions

GHOP, Josip Dzolonga
(Added Java example.)
(GHOP, Josip Dzolonga)
Line 25:
}
}
 
=={{header|Python}}==
def insertion_sort(l):
for i in xrange(1, len(l)):
j = i-1
key = l[i]
while (l[j] > key) and (j >= 0):
l[j+1] = l[j]
j -= 1
l[j+1] = key
Anonymous user