Demographics in Programming Teams in Early CS Courses
I avoid using protected characteristics for any kind of group/class allocation. Personally, I apply a similar approach that I use in experimental research: the randomized block design. Typically, I use levels of prior relevant experience, either self-reported by the students at their point of admission or their grade for their pre-requisite class, as the blocks.