added sort functionality