Fix row selection when table is sorted