先发一个我前面帖子所说的排序方法的完整程序:- ;;;(strsort strlst) = 含数字后缀的字符串排序-无痕.2004.6 ok!
- (defun strsort (strlst)
- (defun strbrk (str / i st1 n)
- (setq i 0)
- (while (not(or(= "" (setq st1(substr str(setq i(1+ i)))))(setq n(distof st1)))))
- (list (substr str 1 (1- i)) (if n n 0) str)
- )
- (defun x-sort (lst do n)
- (vl-sort lst '(lambda(x y)((eval do)(nth n x)(nth n y))))
- )
- (mapcar 'last (x-sort (x-sort (mapcar 'strbrk strlst) '< 1) '< 0))
- )
测试:;(setq lst '("w45""w-3""s""z1""z-4""df676""df24""bff4""bff""bff2""A34""A""A2""A5""bff-5"))
;(strsort lst) ->("A" "A2" "A5" "A34" "bff-5" "bff" "bff2" "bff4" "df24" "df676" "s" "w-3" "w45" "z-4" "z1") |