;;; SEQUENCES 3: SORT, :KEY, REVERSE (solution) (defun ascending (xs) (sort xs #'<)) (defun by-price (alist) (sort alist #'< :key #'cdr)) (defun back-words (xs) (mapcar #'reverse xs)) ;;; ------------------------------------------------------------------ ;;; Checks. Read them - they tell you what to aim for - but leave ;;; them unchanged. ;;; ------------------------------------------------------------------ (check-equal '(1 2 3) (ascending (list 3 1 2))) (check-equal '(-1 0 4) (ascending (list 4 0 -1))) (check-equal '(3 2 1) (reverse (list 1 2 3))) (check-equal '((tea . 1) (cola . 2)) (by-price (list (cons 'cola 2) (cons 'tea 1)))) (check-equal '((b . 1) (c . 2) (a . 7)) (by-price (list (cons 'a 7) (cons 'b 1) (cons 'c 2)))) (check-equal '("tac" "esaelp") (back-words '("cat" "please"))) (check-equal '("bba" "aa") (back-words '("abb" "aa")))