added sort function to table