The (rnrs sorting (6))
library provides procedures for sorting lists
and vectors.
[R6RS+][SRFI-132] Proc should accept any two elements of list or vector. Proc should return a true value when its first argument is strictly less than its second, and #f otherwise.
The list-sort
and vector-sort
procedures perform a stable sort
of list or vector in ascending order according to proc, without
changing list or vector in any way. The list-sort
procedure
returns a list, and vector-sort
returns a vector. The results may be
eq?
to the argument when the argument is already sorted, and the result
of list-sort
may share structure with a tail of the original list. The
sorting algorithm performs O(n lg n) calls to proc where n is the length
of list or vector, and all arguments passed to proc are
elements of the list or vector being sorted, but the pairing of
arguments and the sequencing of calls to proc are not specified. If
multiple returns occur from list-sort
or vector-sort
, the
return values returned by earlier returns are not mutated.
If the optional argument start and end for vector-sort
is specified, then the sorting range is restricted by the given start(inclusive) and end (exclusive).
[R6RS+][SRFI-132] Proc should accept any two elements of the vector, and should not have any side effects. Proc should return a true value when its first argument is strictly less than its second, and #f otherwise.
The vector-sort!
procedure destructively sorts vector in
ascending order according to proc.
If the optional argument start and end is specified, then the sorting range is restricted by the given start (inclusive) and end (exclusive).