column sorting to query