Anonymous user
Sorting algorithms/Counting sort: Difference between revisions
m
→{{header|REXX}}: changed whitespace and comments. enclosed list in quotes.
m (→version 2: added other reasons for improvement.) |
m (→{{header|REXX}}: changed whitespace and comments. enclosed list in quotes.) |
||
Line 2,717:
===version 1===
<lang rexx>/*REXX pgm sorts an array of integers (can be negative) using the count─sort algorithm.*/
$= '1 3 6 2 7 13 20 12 21 11 22 10 23 9 24 8 25 43 62 42 63 41 18 42 17 43 16 44 15 45 14 46 79 113 78 114 77 39 78 38'
#= words($); w= length(#);
m=
do
end /*
/*W: max index width for the @. array*/
call show 'before sort: ' /*show the before array elements. */
say copies('
call countSort # /*sort a number of entries of @. array.*/
call show ' after sort: ' /*show the after array elements. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
countSort: parse arg N; x= 1; do k=LO to HI;
end /*k*/
return
|