Fix crash when sorting one table in the Browse Tab and changing to another

Fix a crash when sorting the n-th column of a table in the Browse Tab
and then changing to a table with less than n columns.