Updated and simplified sort method