I just had the (mis)fortune on having to start running Autocad 2011. I still use the rather ancient DDCHPROP.LSP, which is broken in 2011 because the acad_strlsort function is broken. I've patched DDCHPROP for now by substitution the following code, but I thought I should ask if there is a better solution/replacement. The first line in the lisp file I took this from is ";;; Michels Visual LISP Functions". I'm not sure where or when I found it. No copyright notice in the file.
(defun strl_sort (f_stringlist / f_numl f_strl f_n f_cur) ; similar to acad_strlsort, but sorts string representing numbers numberically
(setq f_numl nil
f_strl nil
)
(foreach f_n f_stringlist ; loop through each element in list
(progn
(if (numberp (read f_n)) ; test if number
(setq f_numl (append f_numl (list f_n))) ; create list of numbers
(setq f_strl (append f_strl (list f_n))) ; create list of strings
)
)
)
(setq f_stringlist nil)
(repeat (length f_numl) ; loop through list of numbers
(progn
(setq f_cur (car f_numl))
(foreach f_n (cdr f_numl) ; loop through remainder of number list
(if (> (read f_cur) (read f_n)) ; test if current value smaller than elements in list
(setq f_cur f_n) ; if so replace current value with smaller value
)
)
(setq f_numl (remove f_cur f_numl)) ; remove current (smallest) value from number list
(setq f_stringlist (append f_stringlist (list f_cur))) ; add current (smallest) value to end of final list
)
)
(repeat (length f_strl) ; loop through list of strings
(progn
(setq f_cur (car f_strl))
(foreach f_n (cdr f_strl) ; loop though remainder of string list
(if (> f_cur f_n) ; test for alphabetical order
(setq f_cur f_n) ; replace current value for precending value
)
)
(setq f_strl (remove f_cur f_strl)) ; remove current value from string list
(setq f_stringlist (append f_stringlist (list f_cur))) ; add current value to end of final list
)
)
)
;eg (strl_sort '("b" "a" "10" "1")) = ("1" "10" "a" "b")
(defun remove (f_new f_newlist / f_test) ; removes first occurance of an element from a list
(if (member f_new f_newlist) ; is value present in list
(progn
(setq f_test nil) ; test to see if element removed
(repeat (length f_newlist) ; loop through list
(progn
(if (not (and (= f_test nil) (= (car f_newlist) f_new))) ; test if element removed or element is to be removed
(setq f_newlist (cdr (append f_newlist (list (car f_newlist))))) ; swaps moves first element to end of list
(progn
(setq f_test t) ; element has been removed
(setq f_newlist (cdr f_newlist)) ; remove first element from list
)
)
)
)
)
)
)
;eg (remove 1 '(1 1 2 1)) = (1 2 1)