Sorting algorithms/Bubble sort: Difference between revisions
Content added Content deleted
(Added ><> (Fish)) |
|||
Line 1,015: | Line 1,015: | ||
Natural: { 1489 3140 3199 3707 4661 5045 6322 6506 7195 8844 } |
Natural: { 1489 3140 3199 3707 4661 5045 6322 6506 7195 8844 } |
||
Reverse: { 8844 7195 6506 6322 5045 4661 3707 3199 3140 1489 } |
Reverse: { 8844 7195 6506 6322 5045 4661 3707 3199 3140 1489 } |
||
=={{header|Fish}}== |
|||
This is not a complete implementation of bubblesort: it doesn't keep a boolean flag whether to stop, so it goes on printing each stage of the sorting process ad infinitum. |
|||
<lang fish>v Sorts the (pre-loaded) stack |
|||
with bubblesort. |
|||
v < |
|||
\l0=?;l& |
|||
>&:1=?v1-&2[$:{:{](?${ |
|||
>~{ao ^ |
|||
>~}l &{ v |
|||
o","{n:&-1^?=0:&<</lang> |
|||
=={{header|Forth}}== |
=={{header|Forth}}== |