Function: cl-sort
cl-sort is an autoloaded and byte-compiled function defined in
cl-seq.el.gz.
Signature
(cl-sort SEQ PREDICATE [KEYWORD VALUE]...)
Documentation
Sort the argument SEQ according to PREDICATE.
This is a destructive function; it reuses the storage of SEQ if possible.
Keywords supported: :key
Aliases
sort* (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-seq.el.gz
;;;###autoload
(defun cl-sort (seq pred &rest cl-keys)
"Sort the argument SEQ according to PREDICATE.
This is a destructive function; it reuses the storage of SEQ if possible.
\nKeywords supported: :key
\n(fn SEQ PREDICATE [KEYWORD VALUE]...)"
;; It's safe to ignore the return value when used on arrays,
;; but most calls pass lists.
(declare (important-return-value t))
(if (nlistp seq)
(if (stringp seq)
(concat (apply #'cl-sort (vconcat seq) pred cl-keys))
(cl-replace seq
(apply #'cl-sort (append seq nil) pred cl-keys)))
(cl--parsing-keywords (:key) ()
(if (memq cl-key '(nil identity))
(sort seq pred)
(sort seq (lambda (x y)
(funcall pred (funcall cl-key x)
(funcall cl-key y))))))))