Query tasks by scheduled date *and* scheduled time

I’d like to be able to view my tasks sorted by time as well as date. Currently, I have this query:

{:title [:h3 "habits"]
:query [:find (pull ?h [*])
:in $ ?start ?today
     [?h :block/marker ?m]
     (page-ref ?h "habit")
     [(contains? #{"TODO" "DOING"} ?m)]
     [?h :block/scheduled ?d]
     [(> ?d ?start)]
      [(< ?d ?today)]]
:inputs [:2d-before :tomorrow]
:result-transform (fn [result]
     (sort-by (fn [d] (get-in d [:block/scheduled])) result))
:breadcrumb-show? false
:table-view? false

That produces the following:

In the above screenshot, “pm routine” is listed before “eat breakfast”, even though “eat breakfast” is scheduled at an earlier time. As far as I can tell, this is not an error with the pages or the sorting of the query. If I schedule “eat breakfast” on the next day, then the query orders the TODOs chronologically:


But when I have two or more tasks due on the same day, but at different times, they seem to be sorted by page title instead of time. Since “am routine” and “pm routine” were on the same page in the above screenshot, they are listed together. If I move “pm routine” to a different page, it is listed separately from “am routine” but still not chronologically:


I’d like to be able to see a more accurate representation of my day- down to the last minute I schedule a task. Ideally, tasks scheduled on the same day would also be sorted by time.

Please let me know if this can be solved by plugin or an update to my query.

Thank you!