table::sort
On this page
Sorting: every key becomes an order-preserving u64 per row (numbers by
their bits, strings by rank among the distinct values), then a stable
LSD radix sort of (key, row) pairs, last key first. O(n) per key; 11-bit
digits, constant digits skipped. Above PAR_ROWS rows the keys are
encoded and the radix passes run on several workers.
Structs
SortKeySource
pub struct SortKeyOne sort key: a column, its direction and where nulls go.
use table::{asc, desc};
let t = table::table!{ "g": ["b", "a", "b"], "x": [1, 2, 3] };
let s = try t.sort([asc("g"), desc("x")]) catch _ { t };
assert(s.column_at(1).to_options_i64() == [2, 3, 1]);
Nulls before every value.
Nulls after every value.
Functions
ascSource
pub fn asc(name: str) -> SortKey Ascending by name, nulls last.
descSource
pub fn desc(name: str) -> SortKey Descending by name, nulls last.
Implementations
impl Table
Sourcepub fn argsort(§self, keys: List<SortKey>) throws (TableError) -> List<usize> The row order that sorts by
keys(stable: ties keep their order), without moving any data.
Sourcepub fn sort(§self, keys: List<SortKey>) throws (TableError) -> Table The rows ordered by
keys(stable, multi-key; each key ascending or descending with nulls first or last). Strings sort by code point, floats with NaN after every number.nabiuse table::desc; let t = table::table!{ "x": [2.0, none, 3.0, 1.0] }; let s = try t.sort([desc("x").nulls_first()]) catch _ { t }; assert(s.column_at(0).to_options_f64() == [none, 3.0, 2.0, 1.0]);
Sourcepub fn sort_by(§self, names: List<str>) throws (TableError) -> Table Ascending by the columns
names.