 ; ABC - Put text entities in alphabetical order (vertically).
 ; Copyright 1991, 2002 by Rocket Software Ltd.
 ; Give hindsight the leverage it needs.
 (DEFUN C:ABC (/ ss ma lll lln num zz cc)
  (setvar "cmdecho" 0)
 ; Make a list of all text strings.
  (write-line "Select some text entities:")
  (setq ss (ssget (list (cons 0 "text"))))
  (setq num 0)
  (while (setq lll (ssname ss num))
         (setq lln (entget lll))
         (setq num (1+ num))
         (setq ma (cons (cdr (assoc 1 lln)) ma)))
 ; Sort the text list alphabetically.
  (setq ma (acad_strlsort ma))
 ; Find the highest text insertion.
  (while (ssname ss 0)
         (setq num 0)
         (setq zz "(max ")
         (while (setq lll (ssname ss num))
                (setq lln (entget lll))
                (setq num (1+ num))
                (setq zz (strcat zz " " (rtos (caddr (assoc 10 lln)) 2 8))))
         (setq zz (strcat zz ")"))
         (setq hh (eval (read zz)))
 ; Find & modify the highest text.
         (setq num 0)
         (while (setq lll (ssname ss num))
                (setq lln (entget lll))
                (setq num (1+ num))
                (setq nn (caddr (assoc 10 lln)))
                (if (equal nn hh 0.000001)
                    (progn
                          (ssdel lll ss)
                          (setq cc (car ma))
                          (setq ma (cdr ma))
                          (entmod (subst (cons 1 cc) (assoc 1 lln) lln))))))
 (princ))