Anonymous user
Sort an integer array: Difference between revisions
m
→sort a list: added/changed some statements, comments, and whitespace, used a template for the output section.
m (→sort an array: added/changed statements, comments, and whitespace, used a template for the output section, changed output indentation.) |
m (→sort a list: added/changed some statements, comments, and whitespace, used a template for the output section.) |
||
Line 1,674:
===sort a list===
This REXX version creates a list with a bunch of interesting integers, then sorts it.
<br>it is then sorted, and then the list is re-constituted.
<lang rexx>/*REXX program sorts (using E─sort) and displays a list of some interesting integers. */
Bell= 1 1 2 5 15 52 203 877 4140 21147 115975 /*a few Bell " */
Line 1,694 ⟶ 1,695:
exit /*stick a fork in it, we're all done.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
eSort: procedure expose @.; parse arg N; h=N
parse value @.j @.k with @.k @.j /*swap two
if h>=j then leave; j= j-h; k= k-h /*this part sorted?*/
end /*while @.k<@.j*/
end /*i*/
end
return</lang>
{{out|output|text= when using the default internal inputs:}}
<pre>
unsorted = 1 1 2 5 15 52 203 877 4140 21147 115975 1 -1 1 0 -1 0 1 0 -1 0 5 0 -691 0 7 0 -3617 3 0 2 3 2 5 5 7 10 12 17 22 29 39 51 68 90
|