Fix sorting on tables