Completed sort_by