Simplify the query string sorting