Anonymous user
Sorting algorithms/Radix sort: Difference between revisions
m
→{{header|REXX}}: added boilerplate to the sort's preamble.
Drkameleon (talk | contribs) |
m (→{{header|REXX}}: added boilerplate to the sort's preamble.) |
||
Line 2,858:
<lang rexx>/*REXX program performs a radix sort on an integer array (can be negative/zero/positive)*/
call gen /*call subroutine to generate numbers. */
call radSort n,
call show /*display the elements in the @ array*/
exit
/*──────────────────────────────────────────────────────────────────────────────────────*/
gen: ILF= 0 2 3 4 5 5 7. 6 6 7 11 7 13 9 8 8 17 8 19 9 10 13 23 9 10 15 ,
Line 2,872:
end /*m*/; return /*W: is the maximum width ↑ of numbers*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
radSort: procedure expose @.
!.#._b= 1; if w=='' then w= 8
!.#._i= 1; do i=1 for size; y=@.i; @.i= right(abs(y), w, 0); if y<0 then @.i= '-'@.i
end /*i*/ /* [↑] negative case.*/
|