Added custom sort functionality