- (defun sort-xy(li no / s-x s-y)
- (defun s-x (li )(vl-sort li '(lambda(x y)(< (car x)(car y)))))
- (defun s-y (li )(vl-sort li '(lambda(x y)(< (cadr x)(cadr y)))))
- (cond((= no 0)(s-x li) )
- ((= no 1)(s-y li ) )
- ((= no 2) (s-x(s-y li)))
- ((= no 3)(s-y(s-x li)))
- )
- )
(sort-xy ptn 0) ...
其实不好,应该下面更好
- (defun sort-xy (li how / a)
- (if(setq a(car how))(setq li(vl-sort li '(lambda(x y)((eval a)(car x)(car y))))))
- (if(setq a(cadr how))(setq li(vl-sort li '(lambda(x y)((eval a)(cadr x)(cadr y))))))
- li
- )
(sort-xy li '(< >)) x:< y: >
(sort-xy li '(>)) x:>
(sort-xy li '(nil >)) y:>
(sort-xy li '(> >) ...... |