Sorting algorithms/Insertion sort: Difference between revisions

Added SNOBOL4
(Added SNOBOL4)
Line 660:
 
Original source: [http://seed7.sourceforge.net/algorith/sorting.htm#insertionSort]
 
=={{header|SNOBOL4}}==
<lang snobol>* read data into an array
A = table()
i = 0
readln A<i = i + 1> = trim(input) :s(readln)
aSize = i - 1
 
* sort array
i = 1
loop1 value = A<i>
j = i - 1
loop2 gt(j,0) gt(A<j>,value) :f(done2)
A<j + 1> = A<j>
j = j - 1 :(loop2)
done2 A<j + 1> = value
i = ?lt(i,aSize) i + 1 :s(loop1)
i = 1
 
* output sorted data
while output = A<i>; i = ?lt(i,aSize) i + 1 :s(while)
end</lang>
 
 
=={{header|Standard ML}}==
Anonymous user