SORT

Synopsis
SORT sequence
(SORT sequence predicate)
Description

Sorts a sequence (list, array, or word) in ascending order, or according to a given predicate. The output is a new sequence of the same type as sequence that contains the same items ordered such that there are no two successive items, a and b, where (predicate a b) is FALSE and (predicate b a) is TRUE.

The predicate input must be a procedure that inputs two values and outputs either TRUE or FALSE.

If the sequence input is a list and no predicate input is given, then the output is a list that is sorted by LESSP.

If the sequence input is an array and no predicate input is given, then the output is a new array that is sorted by LESSP.

If the sequence input is a word and no predicate input is given, then the output is a word that is sorted by BEFOREP.

Example
SORT [3 1 2]
[1 2 3]

(SORT [3 1 2] "GREATERP)
[3 2 1]

SourceForge.net Logo