First, welcome to CadTutor.
Although the selection set is a list of sorts, It might be more efficient to convert the Selection Set to a list. Lisp is after all LISt Processing, and has numerous functions for processing lists not immediately available when processing a Selection Set.
Add four text items to a new drawing in the following order "a" "test" "of" "text items"
Get a selection set of text items (taken from your code)
(setq ss (ssget (list '(0 . "TEXT"))))
Depending on the method used their order in the selection set will be reverse order of creation when using crossing or window or order selected if picked individually
(repeat (setq cnt (sslength ss))
(setq ss_lst (cons (ssname ss (setq cnt (1- cnt))) ss_lst))
);end_repeat
will convert the selection set into a list of entity names in the same order as they were in the selection set, by starting at the end and adding each new item to the front of the list.
If you the want the text string of each item you can use the mapcar function along with the anonymous lambda function to process your list of entities extracting the text string
(setq txt_lst (mapcar '(lambda (x) (cdr (assoc 1 (entget x)))) ss_lst))
Here a new list is constructed by taking every item in order from ss_lst and feeding it to the lambda where the item becomes x
This text list (txt_lst) will be in the same order as the entity list (ss_lst)
If you want to find the location of a specific text string you can use one of the visual lisp functions vl-position
(setq find "of")
(setq pos (vl-position find txt_lst))
This assigns to the variable pos the zero based index number of "of" in the list. If you then want the entity name of the text "of" it can be obtained using the nth function
(setq ent (nth pos ss_lst))
If you want to remove and item from a list
(setq txt_lst (vl-remove-if '(lambda (x) (= (nth pos txt_lst) x)) txt_lst))
;;or
(setq ss_lst (vl-remove-if '(lambda (x) (= (nth pos ss_lst) x)) ss_lst))
;;if you want to delete the entity do it before removing it from the list
;;or store it in another list of items to be deleted later
(entdel (nth pos ss_lst))
(setq ss_lst (vl-remove-if '(lambda (x) (= (nth pos ss_lst) x)) ss_lst))
(setq delete_lst (cons (nth pos ss_lst) delete_lst))
(setq ss_lst (vl-remove-if '(lambda (x) (= (nth pos ss_lst) x)) ss_lst))
;;then later
(foreach itm delete_lst (entdel itm))