Add support for sorting query results