Anonymous user
Sorting algorithms/Gnome sort: Difference between revisions
m
→version 1: changed whitespace and indentations, aligned statements better.
(Added Rust solution) |
m (→version 1: changed whitespace and indentations, aligned statements better.) |
||
Line 2,474:
This REXX version uses an unity-based array (instead of a zero-based array).
<lang rexx>/*REXX program sorts an array using the gnome sort algorithm (elements contain blanks). */
call
call
call
call
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 2,486:
do #=1 while @.#\==''; end; #= #-1; w= length(#); return /*get #items*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
gnomeSort: procedure expose @.; parse arg n; k= 2
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: do j=1 for #; say ' element' right(j, w) arg(1)":" @.j; end;
{{out|output|:}}
<pre>
|