Modularize the sort methods and add the result method