Function: denote-sort-files
denote-sort-files is an autoloaded and byte-compiled function defined
in denote.el.
Signature
(denote-sort-files FILES COMPONENT &optional REVERSE)
Documentation
Returned sorted list of Denote FILES.
With COMPONENT as a symbol among denote-sort-components,
sort files based on the corresponding file name component.
With COMPONENT as the symbol of a function, use it to perform the
sorting. In this case, the function is called with two arguments, as
described by sort.
With COMPONENT as a nil value keep the original date-based sorting which relies on the identifier of each file name.
With optional REVERSE as a non-nil value, reverse the sort order.
Source Code
;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
;;;###autoload
(defun denote-sort-files (files component &optional reverse)
"Returned sorted list of Denote FILES.
With COMPONENT as a symbol among `denote-sort-components',
sort files based on the corresponding file name component.
With COMPONENT as the symbol of a function, use it to perform the
sorting. In this case, the function is called with two arguments, as
described by `sort'.
With COMPONENT as a nil value keep the original date-based
sorting which relies on the identifier of each file name.
With optional REVERSE as a non-nil value, reverse the sort order."
(let ((files-to-sort (copy-sequence files)))
(if (eq component 'random)
(denote-sort-random files)
(let* ((sort-fn (pcase component
((pred functionp) component)
('identifier #'denote-sort-identifier-lessp)
('title #'denote-sort-title-lessp)
('keywords #'denote-sort-keywords-lessp)
('signature #'denote-sort-signature-lessp)
('last-modified #'denote-sort-modified-time-greaterp)))
(sorted-files (if sort-fn
(sort files sort-fn)
files-to-sort)))
(if reverse
(reverse sorted-files)
sorted-files)))))