The 'sort' function sorts the 'list' using the 'test' to order the list. The 'sort' function is destructive and modifies the 'list'.
(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'. [I still haven't tested this with Nyquist.]
Common Lisp: 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.
See the
sort
function in the