Function: hierarchy-sort
hierarchy-sort is a byte-compiled function defined in hierarchy.el.gz.
Signature
(hierarchy-sort HIERARCHY &optional SORTFN)
Documentation
Modify HIERARCHY so that its roots and item's children are sorted.
SORTFN is a function taking two items of the hierarchy as parameter and
returning non-nil if the first parameter is lower than the second. By
default, SORTFN is string-lessp.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/hierarchy.el.gz
(defun hierarchy-sort (hierarchy &optional sortfn)
"Modify HIERARCHY so that its roots and item's children are sorted.
SORTFN is a function taking two items of the hierarchy as parameter and
returning non-nil if the first parameter is lower than the second. By
default, SORTFN is `string-lessp'."
(let ((sortfn (or sortfn #'string-lessp)))
(hierarchy--sort-roots hierarchy sortfn)
(mapc (lambda (parent)
(setf
(map-elt (hierarchy--children hierarchy) parent)
(sort (map-elt (hierarchy--children hierarchy) parent) sortfn)))
(map-keys (hierarchy--children hierarchy)))))