Plaster

common-lisp
CL-USER> (defun bubble-sort (list &key (compare #'>)) (let ((sorted nil)) (loop until sorted do (setf sorted t) (loop for cons on list for (value value* . rest) = cons unless (or (null (rest cons)) (not (funcall compare value value*))) do (progn (rotatef (first cons) (second cons)) (setf sorted nil))))) list) WARNING: redefining COMMON-LISP-USER::BUBBLE-SORT in DEFUN BUBBLE-SORT CL-USER> (bubble-sort '(1 8 7 5 6 0 7 3 4)) (0 1 3 4 5 6 7 7 8)