Function: minibuffer--sort-by-position

minibuffer--sort-by-position is a byte-compiled function defined in minibuffer.el.gz.

Signature

(minibuffer--sort-by-position HIST ELEMS)

Documentation

Sort ELEMS by their position in HIST.

Source Code

;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun minibuffer--sort-by-position (hist elems)
  "Sort ELEMS by their position in HIST."
  (let ((hash (make-hash-table :test #'equal :size (length hist)))
        (index 0))
    ;; Record positions in hash
    (dolist (c hist)
      (unless (gethash c hash)
        (puthash c index hash))
      (cl-incf index))
    (minibuffer--sort-by-key
     elems (lambda (x) (gethash x hash most-positive-fixnum)))))