RadixSort module

sort

procedure · 6 overloadsSource

Ranks count numbers at input from smallest to largest, or all of an array view; supports u32, u64 and float.

The input is left as it is and the result is read back through rank. Equal values keep their input order. For float, -0.0 sorts before 0.0 and NaNs sort to the ends by their bit pattern (positive ones last). An empty input (or a null pointer) gives valid, empty ranks: any earlier ranks are dropped, reorder of an empty array works and rank of any index fails its range assert. The count is a u32.

ExampleOpen in playground ↗
sorter: RadixSort;
values := float.[2.5, -1, 9, 0];
sort(*sorter, values);

smallest := values[rank(*sorter, 0)];
largest := values[rank(*sorter, 3)];
assert(smallest == -1 && largest == 9);
free_resources(*sorter);
sort :: (radix: *RadixSort, input: *u32, count: u32)

Parameters

radix: *RadixSort
input: *u32
count: u32
sort :: (radix: *RadixSort, input: *u64, count: u32)

Parameters

radix: *RadixSort
input: *u64
count: u32
sort :: (radix: *RadixSort, input: *float, count: u32)

Parameters

radix: *RadixSort
input: *float
count: u32
sort :: (radix: *RadixSort, input: [] u32)

Parameters

radix: *RadixSort
input: [] u32
sort :: (radix: *RadixSort, input: [] u64)

Parameters

radix: *RadixSort
input: [] u64
sort :: (radix: *RadixSort, input: [] float)

Parameters

radix: *RadixSort
input: [] float

See also