Adding sort functionality