Anonymous user
Sorting algorithms/Radix sort: Difference between revisions
m
→{{header|Tailspin}}: syntax update
m (→{{header|Tailspin}}: syntax update) |
m (→{{header|Tailspin}}: syntax update) |
||
Line 2,586:
<lang tailspin>
templates radixsort@{base:}
def value: $;
$ / $@radixsort.digit -> #
Line 2,600:
// Negatives get completed in wrong length-order, we need to collect by length and correct at the end
@: { done: 1, digit: 1, positives: [], negatives: [[]], buckets: [1..$base -> []]};
$...
$@.done -> #
<1>
Line 2,608:
..|@: {done: 1, digit: $@.digit * $base, buckets:[1..$base -> []]};
..|@.negatives: [];
$previous... ...
$@.done -> #
end radixsort
[170, 45, 75, 91, 90, 92, 802, 24, 2, 66] -> radixsort@{base:10} -> !OUT::write
'
|