Fix troubles when data is sorted