Sorting sublist in common lisp

common-lisp, lisp, sorting, sublist

Solution

I hope I understand your question correctly.

What you need is `:key (lambda (x) (second (car x)))`.

However, you do not even need `lambda`:

(cadar '(((A) 8)))
==> 8

so `:key #'cadar` is your friend.

Problem

Very Simple with this, `(sort L #'> :key #'second))`, I can sort, `(((C) 1) ((D) 1) ((E) 1) ((F) 1) ((G) 1) ((H) 1) ((B) 3) ((A) 8))` But now I want to sort, `((((A) 8)) (((B) 3)) (((C) 1)) (((D) 1)) (((E) 1)) (((F) 1)) (((G) 1)) (((H) 1)))`. What do i need to do to, `(sort L #'> :key #'second))`, to get the second list to sort?

Original source