Anonymous user
Sorting algorithms/Counting sort: Difference between revisions
m
→version 1: added/changed whitespace and comments.
m (→{{header|PHP}}) |
m (→version 1: added/changed whitespace and comments.) |
||
Line 1,778:
Negative, zero, and positive integers are supported.
===version 1===
<lang rexx>/*REXX program sorts an array 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($);
@.
call show
call
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
countSort: procedure expose
do k=L to h; do x=x for _.k; @.x=k; end /*x*/; end /*k*/
return
/*────────────────────────────────────────────────────────────────────────────*/
show
'''output'''
<pre style="height:50ex">
Line 1,880 ⟶ 1,878:
element 39 after sort: 113
element 40 after sort: 114
</pre>
|