Default date sort does not take into account the :closed property
- Dominant language
- Emacs Lisp
- Stars
- 1.6k
- Forks
- 120
- PR merge metrics
- No merged PRs in 30d
Description
### OS/platform
Linux
### Emacs version and provenance
GNU Emacs 30.0.50 built with nix
### Emacs command
emacs
### Org version and provenance
Org mode version 9.6.7 from nix
### org-ql package version and provenance
0.7.1-pre from nix emacs-overlay
### Actions taken
Custom format of a org-ql-select results
### Observed results
The entries with a `:closed` date appears out of order
### Expected results
The entries should be order similarly than in org-ql-search
### Backtrace
Here is the problematic call:
```elisp
(org-ql-select "~/org/projects.org"
'(and (done) (ts :from -3 :to today))
:action 'element-with-markers
:sort '(date reversed))
```
And here is a workaround:
```elisp
(defun tc/compare-entry (b a)
"Order entry A and B so that they appears from newest to oldest.
This is like org-ql--date< but considering closed date too."
(cl-macrolet ((ts (item)
`(or (org-element-property :closed ,item)
(org-element-property :deadline ,item)
(org-element-property :scheduled ,item))))
(org-ql--org-timestamp-element< (ts a) (ts b))))
(org-ql-select "~/org/projects.org"
'(and (done) (ts :from -3 :to today))
:action 'element-with-markers
:sort 'tc/compare-entry)
```
### Etc.
Not sure if that is a bug of feature request.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.