Function: tabulated-list--get-sorter
tabulated-list--get-sorter is a byte-compiled function defined in
tabulated-list.el.gz.
Signature
(tabulated-list--get-sorter)
Documentation
Return a sorting predicate for the current tabulated-list.
Return nil if tabulated-list-sort-key specifies an unsortable
column. Negate the predicate that would be returned if
tabulated-list-sort-key has a non-nil cdr.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/tabulated-list.el.gz
(defun tabulated-list--get-sorter ()
"Return a sorting predicate for the current tabulated-list.
Return nil if `tabulated-list-sort-key' specifies an unsortable
column. Negate the predicate that would be returned if
`tabulated-list-sort-key' has a non-nil cdr."
(when (and tabulated-list-sort-key
(car tabulated-list-sort-key))
(let* ((sort-column (car tabulated-list-sort-key))
(n (tabulated-list--column-number sort-column))
(sorter (nth 2 (aref tabulated-list-format n))))
(when (eq sorter t); Default sorter checks column N:
(setq sorter (lambda (A B)
(let ((a (aref (cadr A) n))
(b (aref (cadr B) n)))
(string< (if (stringp a) a (car a))
(if (stringp b) b (car b)))))))
;; Reversed order.
(if (cdr tabulated-list-sort-key)
(lambda (a b) (funcall sorter b a))
sorter))))