adding sort functionality