Clean up table sort implementation.