本帖最后由 xyp1964 于 2017-11-20 21:52 编辑
- (defun xyp-Sort-PList (lst mode / x y)
- (defun aaa (lst fun1 fun2 / x y x1 x2 y1 y2)
- (vl-sort lst
- '(lambda (x y)
- (setq x1 (caar x)
- x2 (caar y)
- y1 (cadar x)
- y2 (cadar y)
- )
- (cond ((and (= x1 x2) (= y1 y2) (> (caddar x) (caddar y))) T)
- ((and (= y1 y2) (fun1 x1 x2)) T)
- ((fun2 y1 y2) T)
- (T nil)
- )
- )
- )
- )
- (defun bbb (lst fun1 fun2 / x y x1 x2 y1 y2 z1 z2)
- (vl-sort lst
- '(lambda (x y)
- (setq x1 (caar x)
- x2 (caar y)
- y1 (cadar x)
- y2 (cadar y)
- )
- (cond ((and (= x1 x2) (= y1 y2) (> (caddar x) (caddar y))) T)
- ((and (= x1 x2) (fun1 y1 y2)) T)
- ((fun2 x1 x2) T)
- (T nil)
- )
- )
- )
- )
- (cond ((= mode 1) (aaa lst < >)) ; 上→下,左→右
- ((= mode 2) (aaa lst > >)) ; 上→下,右→左
- ((= mode 3) (aaa lst < <)) ; 下→上,左→右
- ((= mode 4) (aaa lst > <)) ; 下→上,右→左
- ((= mode 5) (bbb lst < <)) ; 左→右,上→下
- ((= mode 6) (bbb lst > <)) ; 左→右,下→上
- ((= mode 7) (bbb lst > >)) ; 右→左,上→下
- ((= mode 8) (bbb lst < >)) ; 右→左,下→上
- ((= mode 9) ; 单一数值从小到大
- (vl-sort lst '(lambda (x y) (< (car x) (car y))))
- )
- ((= mode 10) ; 单一数值从大到小
- (vl-sort lst '(lambda (x y) (> (car x) (car y))))
- )
- )
- )
|