Anonymous user
Sorting algorithms/Insertion sort: Difference between revisions
Sorting algorithms/Insertion sort (view source)
Revision as of 10:23, 8 December 2007
, 16 years agoGHOP, 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
|