keen/col/sort

Source
This is a standard module and does not need to be explicitly imported.
is-sorted[col, elem] bool(a col) (col, elem) some, elem sorted-key
is-sorted[col, elem, key] bool(a col, f key data(elem)) (col, elem) some, key sorted-key
sort[col, elem] col(a col) (col, elem) list-new, (col, elem) some, col size, elem sorted-key
Sorts the elements from least to greatest. The result satisfies res[i] <= res[i + 1].
sort[t] (t, t)(a (t, t)) t sorted-key
sort[t] (t, t, t) tuple3(a (t, t, t) tuple3) t sorted-key
sort[t] (t, t, t, t) tuple4(a (t, t, t, t) tuple4) t sorted-key
sort[t] (t, t, t, t, t) tuple5(a (t, t, t, t, t) tuple5) t sorted-key
sort[t] (t, t, t, t, t, t) tuple6(a (t, t, t, t, t, t) tuple6) t sorted-key
sort[t] (t, t, t, t, t, t, t) tuple7(a (t, t, t, t, t, t, t) tuple7) t sorted-key
sort[t] (t, t, t, t, t, t, t, t) tuple8(a (t, t, t, t, t, t, t, t) tuple8) t sorted-key
sort[col, elem, k] col(a col, get-key k mut(elem)) (col, elem) list-new, (col, elem) some, col size, k sorted-key
Sorts 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-key
Sorts 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-key
sort-in-place[t] void(a t mut[]) t sorted-key
Sorts in-place from least to greatest.
sort-in-place[t] void(a t buffer-view) t sorted-key
sort=[t, k] void(a t mut[], get-key k mut(t)) k sorted-key
sort=[t, k] void(a t buffer-view, get-key k mut(t)) k sorted-key
sort-permutation[t] nat32[](a t[]) t sorted-key
Returns a permutation that would sort a. Permutation is an array of indices into a.
apply-permutation[t] t[](a t[], permutation nat32[])
invert-permutation nat32[](a nat32[])
Input: a[index] = out-index Output: res[out-index] = index
sort-by-first[t, u] (t[], u[])(a t[], b u[]) t sorted-key
Sort 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-key
Sort a in place, and move elements of b in the same permutation as a.
median[t] t(a t array-view) t sorted-key
If a has an even number of elements, prefers the higher median.
median-of[t, k] k(a t array-view, get-key k mut(t)) k sorted-key
median-by[t, k] t(a t array-view, get-key k mut(t)) k sorted-key
first-n-sorted[t] t[](a t[], n nat32) t sorted-key
Returns the first n elements of the sorted array. May return less than n elements if a is too small
first-n-sorted[t, k] t[](a t[], n nat32, get-key k mut(t)) k sorted-key
nth-sorted[t] t(a t array-view, n nat32) t sorted-key
Equivalent to a.sort[n] but faster
nth-sorted-by[t, k] t(a t array-view, n nat32, get-key k mut(t)) k sorted-key