Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

sort

sort

type: function (subr) 
location: built-in
source file: xllist.c
Common LISP compatible: similar
supported on: all machines

SYNTAX

(sort <list> <test> )
        <list>          -       a list containing elements to be sorted
        <test>          -       the test to use for the sort

DESCRIPTION

The SORT function sorts the <list> using the <test> to order the list. The SORT function is destructive and modifies the <list>.

EXAMPLES

(setq a '(3 1 4 1 5 9 6 7))             ; returns (3 1 4 1 5 9 6 7)
(sort a '<)                             ; returns (1 1 3 4 5 6 7 9)
(print a)                               ; returns (1 1 3 4 5 6 7 9)
                                        ; notice that A is modified
(sort a '> )                            ; returns (9 7 6 5 4 3 1 1)
                                        ;
(sort '("a" "bar" "foo") 'string> )     ; returns ("foo" "bar" "a")

BUG: XLISP returns the proper value, but improperly modifies the symbol or actual <list>.

COMMON LISP COMPATIBILITY: Common LISP allows for a :KEY keyword (which allows a specified function to be run before the ordering takes place), which XLISP does not support.


Go to the first, previous, next, last section, table of contents.