Sorting algorithms/Bubble sort: Difference between revisions

Content added Content deleted
m (→‎{{header|Icon}}: note builtins)
m (fix tags)
Line 678: Line 678:


This code will demonstrate the bubble sort using arguments supplied as arguments. The last sort call on a string rather than a list illustrates how many Icon operators work on different types. The example could be made more general to deal with coercion of types like cset to sting (admittedly an uninteresting example as csets are already sorted).
This code will demonstrate the bubble sort using arguments supplied as arguments. The last sort call on a string rather than a list illustrates how many Icon operators work on different types. The example could be made more general to deal with coercion of types like cset to sting (admittedly an uninteresting example as csets are already sorted).
<pre>procedure main(l2) #: demo bubblesort
<lang Icon>procedure main(l2) #: demo bubblesort


l1 := copy(l2) # list of strings
l1 := copy(l2) # list of strings
Line 711: Line 711:
}
}
return
return
end</pre>
end</lang>


Sample output:
Sample output: