Created the sort method.