separate them into separate lists, then sort each list in turn
(defun test( / entry varnamelist varname testlist)
;test list
(setq testlist '("A1" "A2" "B3" "C2" "B1" "A3" "C3" "B2" "C1"))
(foreach entry testlist
(if(boundp(setq varname(read(strcat"List"(substr entry 1 1 ))))) (set varname (cons entry (eval varname))) (set varname (list entry )) ) (if(not(member varname varnamelist))(setq varnamelist(cons varname varnamelist)))
)
(foreach varname varnamelist
;here's where you can sort each list in turn
;i'm just printing the contents for this sample
(print (eval varname)))
;you'd need to do something like this to clear the lists ;after you're done with them -= to "localize" the variables ;that are created on the fly depending on actual sorting list
;clear lists to localize on the fly variables
(if(and varnamelist
(listp varnamelist))
(foreach entry varnamelist
(set entry nil))
)
;clear vars
;these could just be localized in the parameter list of the function definition above ( / varnamelist varname) (setq varnamelist nil varname nil) (princ)
)
;hope that helps
;there's no error checking - if your list diverged from the simple pattern you give as an example, results may not be what you expect. You really need to know what possible variances your list can have to allow for any possible occurances.