def
counting_sort(a)
min = a.min
max = a.max
counts =
Array
.
new
(max-min+
1
,
0
)
a.
each
do
|n|
counts[n-min] +=
end
(
...counts.size).map{|i| [i+min]*counts[i]}.flatten