Fixing table sort