crow/col/sort.crow
(source)
is-sorted
[col
, elem
] bool
(a
col
) (col
, elem
) iterate
, elem
compare
iterate
compare
sort
[col
, elem
, builder
] col
(a
col
) (col
, elem
, builder
) build
, (col
, elem
) iterate
, col
size
, elem
compare
build
iterate
size
compare
Sorts the elements of a
from least to greatest.
The result satisfies res[i] <= res[i + 1]
.
sort
[col
, elem
, builder
, k
] col
(a
col
, get-key
data
k
(elem
)) (col
, elem
, builder
) build
, (col
, elem
) iterate
, col
size
, k
compare
build
iterate
size
compare
Same as sort
, but use get-key
to get the comparable part of each element.
sort-unique
[col
, elem
, builder
] col
(a
col
) (col
, elem
, builder
) build
, (col
, elem
) iterate
, col
size
, elem
compare
build
iterate
size
compare
Sort and remove duplicates.
That means res[i] < res[i + 1]
for each element in the result.(2, 1, 2) sort-unique
is 1, 2
.
set-sort
[t
] void
(a
t
mut-slice
) t
compare
compare
Sort the elements of a
from least to greatest.
sort=
[t
, k
] void
(a
t
mut[]
, get-key
data
k
(t
)) k
compare
compare
sort=
[t
, k
] void
(a
t
mut-slice
, get-key
data
k
(t
)) k
compare
compare
Like set-sort
, but use get-key
to get the comparable part of each element.