sort function checks if child id is same as primary place id