Sorting algorithms/Insertion sort: Difference between revisions

Content added Content deleted
Line 2,359: Line 2,359:


<syntaxhighlight lang="text">
<syntaxhighlight lang="text">
func sort . d[] .
proc sort . d[] .
for i = 2 to len d[]
for i = 2 to len d[]
h = d[i]
h = d[i]
j = i - 1
j = i - 1
while j >= 1 and h < d[j]
while j >= 1 and h < d[j]
d[j + 1] = d[j]
d[j + 1] = d[j]
j -= 1
j -= 1
.
.
d[j + 1] = h
d[j + 1] = h
.
.
.
.
data[] = [ 29 4 72 44 55 26 27 77 92 5 ]
data[] = [ 29 4 72 44 55 26 27 77 92 5 ]