generate sort in the query_dsl only if to be sorted