sort

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-sequencetest 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]

Exported from

Modifiers

open

Arguments

source-sequenceAn instance of <sequence>.
test:An instance of <function>.  The default is <.
stable:An instance of <object>, treated as a <boolean>.  The default is #f.

Values

result-sequenceAn instance of <sequence>.
Returns a sequence containing the elements of a source sequence sorted into ascending order.
The common-dylan module.
Whenever possible, we have tried to keep the Dylan module pristine and unextended, preferring to add our extensions to separate modules or libraries.
The class of collections whose keys are consecutive integers starting from zero.
The class of objects that can be applied to arguments.
Returns true if its first operand is less than its second operand.
The class of all Dylan objects.
The class of boolean values.