Thank you, I have another challenge, I am trying to use VL-STRING-SEARCH to find "no equiv" as it is attached to the end of the unmatchable sku# like this ("5" . "J-LG-1P-25-NO-CL090-DW <- no equiv")
To adjust the code you shared I did this:
(foreach e (vl-sort (mapcar 'cdr lst) '>)
(IF (= nil (VL-STRING-SEARCH "<- no equiv" e))
(setq l (if (setq a (assoc e l))
(subst (cons e (1+ (cdr a))) a l)
(cons (cons e 1) l)))))
But of course, everything goes haywire. By haywire I mean, it takes this list:
(("9" . "J-LG-1P-50-NO-CL180-DW <- no equiv") ("8" . "J-LG-1P-50-NO-CL180-DW <- no equiv") ("7" . "J-LG-1P-50-NO-CC180-DW <- no equiv") ("6" . "5LG") ("5" . "J-LG-1P-50-NO-CL180-DW <- no equiv") ("4" . "4LG") ("3" . "4LG") ("20" . "4LG") ("2" . "4LG") ("19" . "J-LG-1P-25-NO-CL090-DW <- no equiv") ("18" . "4LG") ("17" . "4LG") ("16" . "4LG") ("15" . "10LG") ("14" . "10LG") ("13" . "5LG") ("12" . "4LG") ("11" . "4LG") ("10" . "J-LG-1P-50-NO-CC180-DW <- no equiv") ("1" . "J-LG-1P-50-NO-CC180-DW <- no equiv"))
and returned this,
(("1" . "10LG") ("1" . "4LG") ("1" . "5LG") ("1" . "no equiv") ("1" . "no equiv") ("1" . "no equiv") ("1" . "no equiv") ("1" . "no equiv") ("1" . "no equiv") ("1" . "no equiv"))
but I was hoping for this:
(("7" . "no equiv") ("2" . "5LG") ("9" . "4LG") ("2" . "10LG"))
I hope that makes sense.
Thank you for your help.