fix a case when sorting is not working as supposed to be.