Fix table sort problem