;;;-*- Mode: Lisp; Package: UTILS -*- (in-package :utils) (defun ensure-keyword (obj) (etypecase obj (keyword obj) (symbol (intern (string-upcase obj) :keyword)) (string (intern (string-upcase obj) :keyword)))) (defun sort-by-key (list key-list pred) (sort (copy-list list) (lambda (a b) (labels ((find-key (key list klist) (if (eq key (car list)) (car klist) (find-key key (cdr list) (cdr klist))))) (funcall pred (find-key a list key-list) (find-key b list key-list)))))) :eof