keen/col/sort
SourceThis is a standard module
and does not need to be explicitly imported.
sort[col, elem, k] col(a col, get-key k mut(elem)) (col, elem) list-new, (col, elem) some, col size, k sorted-keySorts the elements comparing by the result of
get-key.sort-unique[col, elem] col(a col) (col, elem) list-new, (col, elem) some, col size, elem sorted-keySorts and remove duplicates. That means
res[i] < res[i + 1] for each element in the result.sort-unique[col, elem, k] col(a col, get-key k data(elem)) (col, elem) list-new, (col, elem) some, col size, k sorted-keysort-permutation[t] nat32[](a t[]) t sorted-keyReturns a permutation that would sort
a. Permutation is an array of indices into a.sort-by-first[t, u] (t[], u[])(a t[], b u[]) t sorted-keySort
a, and move elements of b in the same permutation as a. This is useful if a and b are parallel arrays, meaning a[i] and b[i] belong together for the same i. Every pair a[i] and b[i], will move to res.a[j] and res.b[j] for some j.sort-in-place-by-first[t, u] void(a t buffer-view, b u buffer-view) t sorted-keySort
a in place, and move elements of b in the same permutation as a.median[t] t(a t array-view) t sorted-keyIf
a has an even number of elements, prefers the higher median.first-n-sorted[t] t[](a t[], n nat32) t sorted-keyReturns the first
n elements of the sorted array. May return less than n elements if a is too small
res[i] <= res[i + 1].