;(xl-sort '((5 12) (21 3) (0 2)) '(lambda (x y)(< (car x)(car y)))) ->((0 2) (5 12) (21 3))
;(xl-sort '(2 9 3 -1 6) '<) -> (-1 2 3 6 9)
;(xl-sort '(-1 3 -1 3 3 9) '<) -> (-1 -1 3 3 3 9)- ;(xl-sort lst fun) = 以取代vl-sort函数,用法相同(lsp)---------------by 无痕(defun xl-sort (lst fun / nlst)
- (foreach n lst (setq nlst (xl-isort n nlst fun)))
- )
- (defun xl-isort (item lst fun / k nlst)
- (setq k T
- nlst (apply 'append (mapcar '(lambda (x)
- (if (and K ((eval fun) item x)) (progn (setq k nil) (list item x)) (list x))
- ) lst))
- )
- (if k (append lst (list item)) nlst)
- )
|