create sort depending on query type