Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: R6RS Standard Libraries   [Contents][Index]


7.6.2.6 rnrs sorting

The (rnrs sorting (6)) library provides procedures for sorting lists and vectors.

Scheme Procedure: list-sort proc list
Scheme Procedure: vector-sort proc vector

These procedures return their input sorted in ascending order, without modifying the original data. proc must be a procedure that takes two elements from the input list or vector as arguments, and returns a true value if the first is “less” than the second, #f otherwise. list-sort returns a list; vector-sort returns a vector.

Both list-sort and vector-sort are implemented in terms of the stable-sort procedure from Guile’s core library. See Sorting, for a discussion of the behavior of that procedure.

Scheme Procedure: vector-sort! proc vector

Performs a destructive, “in-place” sort of vector, using proc as described above to determine an ascending ordering of elements. vector-sort! returns an unspecified value.

This procedure is implemented in terms of the sort! procedure from Guile’s core library. See Sorting, for more information.