Fix the query buil for multiple sort