Sorting algorithms/Gnome sort: Difference between revisions

Content added Content deleted
(Added Algol W)
(→‎{{header|ALGOL 68}}: Sort numbers, as specified in the task)
Line 447: Line 447:


{{works with|ELLA ALGOL 68|Any (with appropriate job cards AND formatted transput statements removed) - tested with release 1.8.8d.fc9.i386}}
{{works with|ELLA ALGOL 68|Any (with appropriate job cards AND formatted transput statements removed) - tested with release 1.8.8d.fc9.i386}}
<syntaxhighlight lang="algol68">MODE SORTSTRUCT = CHAR;
<syntaxhighlight lang="algol68">MODE SORTSTRUCT = INT;


PROC inplace gnome sort = (REF[]SORTSTRUCT list)REF[]SORTSTRUCT:
PROC inplace gnome sort = (REF[]SORTSTRUCT list)REF[]SORTSTRUCT:
Line 467: Line 467:
in place gnome sort(LOC[LWB seq: UPB seq]SORTSTRUCT:=seq);
in place gnome sort(LOC[LWB seq: UPB seq]SORTSTRUCT:=seq);


[]SORTSTRUCT char array data = "big fjords vex quick waltz nymph";
[]SORTSTRUCT unsorted array data = ( -40, 77, 9, 0, 2, 1, 0, 1701 );
print((gnome sort(char array data), new line))</syntaxhighlight>
print((gnome sort(unsorted array data), new line))
</syntaxhighlight>
Output:
Output:
<pre>
<pre>
-40 +0 +0 +1 +2 +9 +77 +1701
abcdefghiijklmnopqrstuvwxyz
</pre>
</pre>