Set sort_order to query before passing.