Sorting for the main table.