added sort functionality to tables