Adding the sort functionality