Anonymous user
Sorting algorithms/Insertion sort: Difference between revisions
m
→{{header|REXX}}: added whitespace and a comment, used a template for the output section.
No edit summary |
m (→{{header|REXX}}: added whitespace and a comment, used a template for the output section.) |
||
Line 3,215:
call gen /*generate the array's (data) elements.*/
call show 'before sort' /*display the before array elements. */
say copies('▒', 85)
call insertionSort # /*invoke the insertion sort. */
call show ' after sort' /*display the after array elements. */
Line 3,230:
@.9 = "But the child that is born on the Sabbath day"
@.10 = "Is blithe and bonny, good and gay."
do #=1 while @.#\==''; end; #= #-1
return /* [↑] adjust # for the DO loop index.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
insertionSort: procedure expose @.; parse arg #
do i=2 to #; $= @.i;
_= j + 1; @._= @.j
end /*j*/
_= j + 1;
end /*i*/
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: do j=1 for #; say ' element' right(j,length(#)) arg(1)": " @.j; end; return</lang>
<pre>
element 1 before sort: ---Monday's Child Is Fair of Face (by Mother Goose)---
|