-
-
Notifications
You must be signed in to change notification settings - Fork 336
Closed
Description
Say I have some candidates as a list of cons cells, and I want them sorted on the cdr of the cell. Is this the right way to do it?
#+BEGIN_SRC emacs-lisp
(defvar ivy-sorter-data '(("b 1" . 1) ("a 2" . 2) ("d 0" . 0) ("c 5" . 5)))
(defun isn (a b)
(< (cdr (assoc a ivy-sorter-data)) (cdr (assoc b ivy-sorter-data))))
(add-to-list 'ivy-sort-functions-alist '(ivy-sorter . isn))
(defun ivy-sorter (&rest args) (mapcar 'car ivy-sorter-data))
(ivy-read "string: " 'ivy-sorter
:sort t)
#+END_SRC
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels