You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies if it's a duplicate -- I searched over issues/prs and didn't find anything existing
I want to sort the results of org-ql-search by a "created" timestamp -- in my case it's either a CREATED property or just a first inactive timestamp in the outline (e.g. * [#B] [2022-08-01 Mon 00:38] some note).
I went through the source code
;; NOTE: Using `reverse' instead of `nreverse' because my gut
;; tells me that, while `nreverse' would be preferable and faster,
;; it would probably cause weird bugs, like items' order being
;; reversed every time a cached query is refreshed in a view.
('reverse (reverse items))
('todo (sort-by-todo-keyword items))
(_ (-sort (sorter pred) items)))))
items))
, and seems that it only supports predefined sorting predicates at the moment?
I'm happy to try and contribute support for custom predicates, just want to double check first that would fit into the library. E.g. I imagine it might have some impact on caching?
I imagine as a workaround I could abuse existing org-ql--date< sorting key and override it to extract the CREATED property or something like that.
Thanks!
The text was updated successfully, but these errors were encountered:
Yes, unlike search predicates with org-ql-defpred, there isn't yet support for easily adding custom sorters. However, there is a WIP branch that would make it easier:
((guard (cl-subsetp (-list sort) '(date deadline scheduled closed todo priority random reverse)))
;; Default sorting functions
(org-ql--sort-by items (-list sort)))
;; Sort by user-given comparator.
((pred functionp) (-sort sort items))
;; FIXME: Test more carefully for sorters with arguments. In the meantime, just try to sort.
(_ (org-ql--sort-by items (-list sort)))
;; (_ (user-error "SORT must be either nil, one or a list of the defined sorting methods (see documentation), or a comparison function of two arguments"))
)))
The disadvantage is possibly providing less useful error messages if a user makes a mistake, but the additional flexibility would probably be worth it, so I'll probably merge something like that eventually.
Apologies if it's a duplicate -- I searched over issues/prs and didn't find anything existing
I want to sort the results of
org-ql-search
by a "created" timestamp -- in my case it's either aCREATED
property or just a first inactive timestamp in the outline (e.g.* [#B] [2022-08-01 Mon 00:38] some note
).I went through the source code
org-ql/org-ql.el
Lines 2400 to 2436 in eb53773
I'm happy to try and contribute support for custom predicates, just want to double check first that would fit into the library. E.g. I imagine it might have some impact on caching?
I imagine as a workaround I could abuse existing
org-ql--date<
sorting key and override it to extract theCREATED
property or something like that.Thanks!
The text was updated successfully, but these errors were encountered: