Sorting algorithms/Counting sort: Difference between revisions

m
(→‎{{header|NetRexx}}: Add a more Rexx-like version)
Line 1,022:
 
===Version 2===
A more Rexx-like (and shorter) version. Due to NetRexx's built in indexed string capability, negative values are also easily supported.
<lang NetRexx>/* NetRexx */
options replace format comments java crossref symbols nobinary
Line 1,045:
end
end ix
return ocounts.space
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method getMinMax(icounts) public constant binary returns Rexx
 
amin = IntegerLong.MAX_VALUE
amax = IntegerLong.MIN_VALUE
loop x_ = 1 to icounts.words
ifamin = icounts.word(x_) < .min(amin then)
aminamax = icounts.word(x_).max(amax)
if icounts.word(x_) > amax then
amax = icounts.word(x_)
end x_
 
Line 1,072 ⟶ 1,070:
 
say icounts.space
say countingSort(icounts).space
 
return
Anonymous user