How to update query from 0.2.3 to 0.3.3

I am trying to update a query that worked in version 0.2.3, but seems trickier to get right in the current version. The query is for what is probably a typical use case: it filters for scheduled blocks in some specified time interval and sorts by their scheduled (or deadline) date:

#+BEGIN_QUERY
{:title [:b “Scheduled”]
:query [:find (pull ?block [*])
:in $ ?start ?next
:where
(or
[?block :block/scheduled ?d]
[?block :block/deadline ?d])
[(>= ?d ?start)]
[(< ?d ?next)]]
:inputs [:today :365d-after]
:result-transform (fn [result]
(sort-by (fn [h]
(get h (or :block/scheduled :block/deadline))) result))
:collapsed? false}
#+END_QUERY

This is what the result looks like in 0.2.3:

That is what I’d expect – the earlier scheduled dates are listed first. Here is the result in 0.3.3:

It is now sorting the returned blocks by their date of creation, ignoring the sort-by clause in the query. Is there a way of updating the query so that the returned result appears as it did in the older version?