Adding sort method to query