Sorting by priority with simple query

I have this simple query “{{query (and (todo todo doing) [[Momolingo]])}}” which gets all my TODOs for a project. I see there’s a “sort-by” for simple queries:

https://logseq.github.io/#/page/61c1f5ab-2a06-408d-b28d-3a90de859288

But don’t see how to make this sort by priority which seem to just be tags. BTW, anyway to have drag-and-drop functionality for prioritizing todos? Some kind of property could be added to the blocks that changes when their drag position is changed I suppose.

2 Likes

Was able to combine simple and advanced queries this way:

#+BEGIN_QUERY
{:title "🔨 All todos with current pages tag"
 :query (and (todo TODO DOING) [[Momolingo]])
:result-transform (fn [result]
                                 (sort-by (fn [h]
                                                  (get h :block/priority "Z")) result))
}
#+END_QUERY
4 Likes

I’ve got this working very well on some of my basic pages (which, thank you for such a simple solution!), but I use a lot of “nested” pages to keep track of various levels of specificity around projects… and that seems to break it! Any ideas about how remedy it to function properly for something like:

#+BEGIN_QUERY
{:title "🔨 All todos with current pages tag"
 :query (and (todo TODO DOING) [[Momolingo/language1]])
:result-transform (fn [result]
                                 (sort-by (fn [h]
                                                  (get h :block/priority "Z")) result))
}
#+END_QUERY

?

I’m still fairly new to logseq, so any advice is greatly appreciated!