In an Org-mode document, let's imagine that my entries are following this pattern:
* TODO Note page 2 [0/1]
my notes, must be at second position after sorting
- [ ] todo 1
* Note page 14 :A_Tag:
my notes, must be at third position after sorting
* Note page 1
my notes, must be at first position after sorting
Question: how to sort these entries according to page number?
Expected result is:
* Note page 1
my notes, must be at first position after sorting
* TODO Note page 2 [0/1]
my notes, must be at second position after sorting
- [ ] todo 1
* Note page 14 :A_Tag:
my notes, must be at third position after sorting
I know the function org-sort-entries
but AFAIK we can not use it with default options. We must define that the sort must be performed according to a pattern like
^* <ignore TODO> Note page [Number] <ignore tag list>$
For instance, if I use org-sort-entries
+ [a] I get:
* Note page 1
my notes, must be at first position after sorting
* Note page 14 :A_Tag:
my notes, must be at second position after sorting
* TODO Note page 2 [0/1]
my notes, must be at third position after sorting
- [ ] todo 1
I get an alphabetically sorted output, however, this is not what I want to do. What is the right way to do that?
----- update
with your function org-page-sort
I get:
* Note page 1
my notes, must be at first position after sorting* TODO Note page 2 [0/1]
my notes, must be at second position after sorting
- [ ] todo 1
* Note page 14 :A_Tag:
my notes, must be at third position after sorting
maybe a little bug. However, I do not see where is the problem as your function prints
looking at page Note page 2 [0/1]
looking at page Note page 14
looking at page Note page 1
as expected.
Anyway thank you very much (I upvoted your answer), this is the kind of solution I was looking for!
org-sort
(which ends up callingorg-sort-entries
) on your example, and it sorts them correctly. This is with org-mode 9.1.14 – rpluim Sep 14 '18 at 11:58