Add sorting options to queries.