rewrote table sort (test)