Changing method for sort operation (Bad index in table)