sortData is in infinite loop