SORTsequence(SORTsequencepredicate)
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 ( is FALSE and predicate a b)( is TRUE.
predicate b a)
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.
SORT [3 1 2][1 2 3](SORT [3 1 2] "GREATERP)[3 2 1]