Only mark a table as unsorted after insertion if it actually is

Signed-off-by: Rick Taylor <rick@tropicalstormsoftware.com>