Since your point IDs are alphanumerical, I would suggest the following function to perform the sort:
Dear Lee Mac, I have used following code :-
(defun c:test ()
(setq rawstringlist
'("1,293194.436,4223954.179,109.130" "10,293119.590,4223876.956,102.977" "11,293111.330,4223873.266,102.524" "12,293094.236,4223865.717"
"13,293090.831,4223873.322,101.531" "14,293088.610,4223878.282,101.471" "15,293082.991,4223890.831" "S22, 1. 2. 3"
"16,293093.239,4223896.909,101.882" "17,293118.988,4223912.366,103.460" "18,293145.312,4223927.679,105.006" "19,293170.059,4223941.093,106.943"
"S12, 1. 2. 3" "2,293192.890,4223941.304,108.846" "20,293182.533,4223947.752,108.027" "3,293192.005,4223933.294,108.766"
"4,293190.314,4223909.952" "5,293185.490,4223908.126" "6,293164.970,4223898.855" "7,293150.456,4223892.212"
"b12, 1. 2. 3" "8,293135.932,4223885.002" "9,293130.982,4223881.708,103.711"
)
)
(setq SortedList1 (SortStringWithNumberAsNumber rawstringlist T))
(setq SortedList2 (LM:alphanumsort rawstringlist))
(foreach xx SortedList1 (princ "\n") (princ xx))
(princ "\n\n")
(foreach xx SortedList2 (princ "\n") (princ xx))
(princ)
)
;;
;;
;;Published http://www.theswamp.org/index.php?topic=16564.0
;;By VVA -- 05.20.07 mods by CAB
;;Usage (SortStringWithNumberAsNumber '("A9" "A1" "A10" "B11" "B2" "B05") nil)
;;With ignore case (SortStringWithNumberAsNumber '("A9" "A1" "A10" "B11" "B2" "B05") t)
;; CAB added Ignore Case Flag as an argument
;;Return ("A1" "A9" "A10" "B2" "B05" "B11")
(defun SortStringWithNumberAsNumber (ListOfString IgnoreCase / NorStrs count)
;;;Function Normalize (add 0 befor number) number in string
;;; Count normalize symbols set in variable count
;;; CAB added count as an argument
(defun NormalizeNumberInString (str count / ch i pat ret buf)
(setq i 0
pat '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")
ret ""
) ;_ end of setq
(while (/= (setq ch (substr str (setq i (1+ i)) 1)) "")
(if (vl-position ch pat)
(progn (setq buf ch) ;_ end of setq
(while (vl-position (setq ch (substr str (setq i (1+ i)) 1)) pat) (setq buf (strcat buf ch))) ;_ end of while
(while (< (strlen buf) count) (setq buf (strcat "0" buf)))
(setq ret (strcat ret buf))
) ;_ end of progn
) ;_ end of if
(setq ret (strcat ret ch))
) ;_ end of while
ret
) ;_ end of defun
;;-------------------------------------------------
;; function to Count the longest number in string
;; CAB added to get the correct COUNT
(defun getcount (lst / count pat)
(setq count 0)
(setq pat '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
(mapcar '(lambda (str / i maxlen ch)
(setq i 0
maxlen 0
)
(while (/= (setq ch (substr str (setq i (1+ i)) 1)) "")
(if (vl-position ch pat) ; number
(setq maxlen (1+ maxlen))
(setq count (max count maxlen)
maxlen 0
)
)
)
(setq count (max count maxlen)) ;_<<< ADD 21.06.2007 by VVA
)
Lst
)
count
)
;;===============================================
(setq count (GetCount ListOfString)
NorStrs (mapcar '(lambda (x) (NormalizeNumberInString x count)) ListOfString)
)
(and IgnoreCase (setq NorStrs (mapcar 'strcase NorStrs)))
(mapcar '(lambda (x) (nth x ListOfString)) (vl-sort-i NorStrs '<))
) ;_ end of defun
;; Alphanumerical Sort - Lee Mac
;; Sorts a list of strings containing a combination of alphabetical & numerical characters.
(defun LM:alphanumsort (lst)
(mapcar (function (lambda (n) (nth n lst)))
(vl-sort-i (mapcar 'LM:splitstring lst)
(function (lambda (a b / x y)
(while (and (setq x (car a)) (setq y (car b)) (= x y))
(setq a (cdr a)
b (cdr b)
)
)
(cond ((null x) b)
((null y) nil)
((and (numberp x) (numberp y)) (< x y))
((numberp x))
((numberp y) nil)
((< x y))
)
)
)
)
)
)
;; Split String - Lee Mac
;; Splits a string into a list of text and numbers
(defun LM:splitstring (str)
((lambda (l)
(read
(strcat "("
(vl-list->string
(apply 'append
(mapcar (function
(lambda (a b c)
(cond ((= 92 b) (list 32 34 92 b 34 32))
((or (< 47 b 58) (and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)))
(list b)
)
((list 32 34 b 34 32))
)
)
)
(cons nil l)
l
(append (cdr l) '(()))
)
)
)
")"
)
)
)
(vl-string->list str)
)
)
I get following output :-
Output as per SortStringWithNumberAsNumber :-1,293194.436,4223954.179,109.130
2,293192.890,4223941.304,108.846
3,293192.005,4223933.294,108.766
4,293190.314,4223909.952
5,293185.490,4223908.126
6,293164.970,4223898.855
7,293150.456,4223892.212
8,293135.932,4223885.002
9,293130.982,4223881.708,103.711
10,293119.590,4223876.956,102.977
11,293111.330,4223873.266,102.524
12,293094.236,4223865.717
13,293090.831,4223873.322,101.531
14,293088.610,4223878.282,101.471
15,293082.991,4223890.831
16,293093.239,4223896.909,101.882
17,293118.988,4223912.366,103.460
18,293145.312,4223927.679,105.006
19,293170.059,4223941.093,106.943
20,293182.533,4223947.752,108.027
b12, 1. 2. 3
S12, 1. 2. 3
S22, 1. 2. 3
Output as per LM:alphanumsort :-1,293194.436,4223954.179,109.130
2,293192.890,4223941.304,108.846
3,293192.005,4223933.294,108.766
4,293190.314,4223909.952
5,293185.490,4223908.126
6,293164.970,4223898.855
7,293150.456,4223892.212
8,293135.932,4223885.002
9,293130.982,4223881.708,103.711
10,293119.590,4223876.956,102.977
11,293111.330,4223873.266,102.524
12,293094.236,4223865.717
13,293090.831,4223873.322,101.531
14,293088.610,4223878.282,101.471
15,293082.991,4223890.831
16,293093.239,4223896.909,101.882
17,293118.988,4223912.366,103.460
18,293145.312,4223927.679,105.006
19,293170.059,4223941.093,106.943
20,293182.533,4223947.752,108.027
S12, 1. 2. 3
S22, 1. 2. 3
b12, 1. 2. 3
If you see the above two outputs, b12, S12, S22 is correct whereas S12,S22,b12 is incorrect.
Please check.