Fix bug when sorting output data on identifying attribute