You can sort lists multi level deep not just x y, and you could sort rows that have 1 2 10 texts. It would have ((x y text) (x y text)…….
This is not finished but close, hansacad not sure how you want to do the answers.
178
46
213
(defun checkstr ( )
(setq tot 0)
(repeat (setq y (length lst2))
(setq strsub (nth (setq y (- y 1)) lst2))
(if (= (wcmatch strsub "*[A-z]*") T)
(princ)
(setq tot (+ (atof strsub) tot))
)
)
(alert (strcat "tot = " (rtos tot 2 3)))
)
(defun ahtest ( / ss obj pt ptx pty str )
(setq ss (ssget (list (cons 0 "*text"))))
(setq lst '())
(repeat (setq x (sslength ss))
(setq obj (entget (ssname ss (setq x (- x 1)))))
(setq pt (cdr (assoc 10 obj)))
(setq ptx (nth 0 pt)
pty (nth 1 pt))
(setq str (cdr (assoc 1 obj)))
(setq lst (cons (list ptx pty str) lst))
)
; sorts on 1st two items
(setq lst (vl-sort lst '(lambda (x y)
(cond
((= (cadr x)(cadr y))
(< (car x)(car y)))
((< (cadr x)(cadr y)))
))))
; now make sublist row at a time by comparing (nth 1 str) value
(setq x 0)
(setq lst2 '())
(setq str1 (nth x lst))
(repeat (-(length lst) 1)
(setq str2 (nth (setq x (+ x 1)) lst))
(setq y1 (nth 1 str1))
(setq y2 (nth 1 str2))
(if (= y1 y2)
(progn
(setq lst2(cons (nth 2 str1) lst2))
(setq str1 str2)
)
(progn
(setq lst2(cons (nth 2 str1) lst2))
(setq str1 str2)
(princ lst2)
(checkstr)
(if (= x (length lst))
(princ)
(setq lst2 '())
)
)
)
)
(setq lst2(cons (nth 2 str1) lst2))
(checkstr)
(princ)
)
(ahtest)