Returns a sequence containing the elements of a source sequence sorted into ascending order. The result-sequence may or may not be freshly allocated. The source-sequence is not modified by this operation.
sort determines the relationship between two elements by giving elements to the test. The first argument to the test function is one element of source-sequence; the second argument is another element of source-sequence. test should return true if and only if the first argument is strictly less than the second (in some appropriate sense). If the first argument is greater than or equal to the second (in the appropriate sense), then the test should return #f.
If stable is supplied and not #f, a possibly slower algorithm will be used that will leave in their original order any two elements, x and y, such that test(x, y) and test(y, x) are both false.
define variable *numbers* = vector(3, 1, 4, 1, 5, 9)
*numbers*
⇒ #[3, 1, 4, 1, 5, 9]
sort (*numbers*)
⇒ #[1, 1, 3, 4, 5, 9]
*numbers*
⇒ #[3, 1, 4, 1, 5, 9]
open
| source-sequence | An instance of <sequence>. |
| test: | An instance of <function>. The default is <. |
| stable: | An instance of <object>, treated as a <boolean>. The default is #f. |
| result-sequence | An instance of <sequence>. |