The young children are still pretty-much sorting themselves by sex when lining up. I've watched it happening. It is completely spontaneous. There is no instruction from any teacher.
I can still remember my own early years in primary school, when students were told by the teacher to line up in two separate lines, one for the girls and one for the boys. It's like were going back to the 1960s in a bloody time machine!