Sorting issue #2 #554
Closed
Sorting issue #2 #554
Comments
Yes, this is a correct approach. Looking at it now, it is quite a bit clunky. I'm adding a commit to make this work: (defvar ivy-sorter-data '(("b 1" . 1) ("a 2" . 2) ("d 0" . 0) ("c 5" . 5)))
(defun isn (a b)
(< (cdr a) (cdr b)))
(add-to-list 'ivy-sort-functions-alist '(ivy-sorter . isn))
(ivy-read "string: " ivy-sorter-data
:sort t
:caller 'ivy-sorter) |
abo-abo
added a commit
that referenced
this issue
Jun 13, 2016
* ivy.el (ivy--reset-state): When an alist is passed to `ivy-read', and a sorting function is associated via 'caller, the sorting function will receive two cons cells as arguments, instead of two strings as usual. Re #554 Example: (defvar ivy-sorter-data '(("b 1" . 1) ("a 2" . 2) ("d 0" . 0) ("c 5" . 5))) (defun isn (a b) (< (cdr a) (cdr b))) (add-to-list 'ivy-sort-functions-alist '(ivy-sorter . isn)) (ivy-read "string: " ivy-sorter-data :sort t :caller 'ivy-sorter)
That is nice, thanks! That makes things like this possible too.
and
|
This one looks resolved, closing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
The text was updated successfully, but these errors were encountered: