Sorting query by referenced journal page

I have been tagging my todos with dates using the date picker (not Scheduled or Deadline because I don’t like the layout with the date on a new line. I have the following query that pulls the next 7 days of todos but I would like to sort it by date. I’ve seen examples sorting by scheduled date but not by dates referenced as links. Can anyone tell me if this is even possible and if so how to do it ?

Thanks

{:title “:date: NEXT”
:query [:find (pull ?h [*])
:in $ ?start ?next
:where
[?h :block/marker ?marker]
[(contains? #{“NOW” “LATER” “TODO” “DOING”} ?marker)]
[?h :block/ref-pages ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(> ?d ?start)]
[(< ?d ?next)]]
:inputs [:today :7d-after]
:result-transform (fn [result]
(sort-by (fn [h]
(get h :block/ref-pages “A”)) result))
:collapsed? false}

1 Like

Did you have any luck? I’m also trying to find the answer to this.