Sorting algorithms/Insertion sort: Difference between revisions

(+Icon+Unicon)
Line 570:
end</lang>
 
Note: This example relies on [[Sorting_algorithms/Bubble_sort#Icon| the supporting procedures 'sortop', and 'demosort' in Bubble Sort]]. The full demosort exercises the named sort of a list with op = "numeric", "string", ">>" (lexically gt, descending),">" (numerically gt, descending), a custom comparator, and also a string.
 
SampleAbbreviated Outputsample output:<pre>Sorting Demo using procedure insertionsort
on list : [ 3 14 1 5 9 2 6 3 ]
with op = &null: [ 1 2 3 3 5 6 9 14 ] (0 ms)
...
with op = "numeric": [ 1 2 3 3 5 6 9 14 ] (0 ms)
with op = "string": [ 1 14 2 3 3 5 6 9 ] (0 ms)
with op = ">>": [ 9 6 5 3 3 2 14 1 ] (0 ms)
with op = ">": [ 14 9 6 5 3 3 2 1 ] (0 ms)
with op = procedure cmp: [ 1 2 3 3 5 6 9 14 ] (0 ms)
with op = "cmp": [ 1 2 3 3 5 6 9 14 ] (0 ms)
on string : "qwerty"
with op = &null: "eqrtwy" (0 ms)</pre>
Anonymous user