Updated sort method.