Sorting on main table