Automatic table sorting (3rd time is the charm)