I always use sort+combination like this below codes
(DEFUN Sort&Comb (lst func / tmplst)
(SETQ tmplst nil)
(FOREACH item (VL-SORT lst
(FUNCTION (LAMBDA (p1 p2) (< (CAR p1) (CAR p2))))
)
(IF (AND tmplst (EQUAL (CAAR tmplst) (CAR item)))
(SETQ tmplst (SUBST (LIST (CAR item)
(APPLY func (LIST (CADR item) (CADAR tmplst)))
)
(CAR tmplst)
tmplst
)
)
(SETQ tmplst (CONS item tmplst))
)
)
tmplst
)
(setq aaa '(("one" 1) ("two" 2) ("three" 3)
("one" 4) ("two" 5) ("three" 6)
("one" 7) ("two" 8) ("three" 9)
)
)
(Sort&Comb aaa '+)
;;return (("two" 15) ("three" 18) ("one" 12))
(Sort&Comb aaa '*)
;;return (("two" 80) ("three" 162) ("one" 28))
(Sort&Comb aaa (FUNCTION (LAMBDA (P1 P2) (IF (ATOM P2) (LIST P1 P2) (CONS P1 P2)))))
;;return (("two" (8 5 2)) ("three" (9 6 3)) ("one" (7 4 1)))