Query engine: fixed column sorting issues