Sort by multiple properties

Changed :test to :categorie and :datum-begin to :datum-aanschaf for use in my query, but it seems to not sort at all.
Also checked the file to make sure there were no hidden sort properties. Even put the query in a fresh block.

Decided to go to a fully new graph.
And there the comp solution also failed.

However the explicit sort does work there. Not sure what is different in my normal graph then. Except blocks vs. pages.

Full page from my new graph:

- Item 1
  categorie:: cat 1
  datum-aanschaf:: 2015-08-29
- Item 2
  categorie:: cat 2
  datum-aanschaf:: 2014-07-17
- Item 3
  categorie:: cat 3
  datum-aanschaf:: 2022-07-11
- Item 4
  categorie:: cat 4
  datum-aanschaf:: 2023-03-15
- Item 5
  categorie:: cat 2
  datum-aanschaf:: 2023-11-14
- Item 6
  categorie:: cat 3
  datum-aanschaf:: 2024-01-06
- Item 7
  categorie:: cat 4
  datum-aanschaf:: 2024-04-25
- Item 8
  categorie:: cat 1
  datum-aanschaf:: 2020-09-25
- Item 9
  categorie:: cat 1
  datum-aanschaf::
- query-table:: true
  query-properties:: [:block :categorie :datum-aanschaf]
#+BEGIN_QUERY
{:title "Sorting"
 :query [:find (pull ?b [*])
  :where
   [?b :block/properties ?prop]
   [(get ?prop :categorie)]
 ]
 :result-transform (fn [result] 
   (sort
     (fn [l r]
       (defn obj-prop [obj prop dflt] (get-in obj [:block/properties-text-values prop] dflt))
       (defn compare-by-prop [l r prop dflt] (compare (obj-prop l prop dflt) (obj-prop r prop dflt)))
       (def t (compare-by-prop l r :categorie))
       (if (not= t 0) t (- (compare-by-prop l r :datum-aanschaf)))
     )
     result
   )
 )
}
#+END_QUERY
- query-table:: true
  query-properties:: [:block :categorie :datum-aanschaf]
#+BEGIN_QUERY
{:title "Sorting"
 :query [:find (pull ?b [*])
  :where
   [?b :block/properties ?prop]
   [(get ?prop :categorie)]
 ]
 :result-transform (fn [result] 
  (sort-by 
   (comp - (fn [r] (get-in r [:block/properties-text-values :datum-aanschaf] "")) )
    result
  )
 )
}
#+END_QUERY

Query result:

Edit: confirmed. It breaks apart when using pages :woman_shrugging:t4:

1 Like