In a course where backgrounds varied, it helped to distribute expertise.
Overriding concern is a time available for group meetings outside class.
I prefer a heterogeneous mix to provide a variety of experiences. I try to have heterogeneous groups by skill level, and not put one female with 3 males or vice-versa. Either 2 of each or one sex in groups. A couple of times I have tried to get students to form study groups to meet regularly outside of class. In those cases I helped form groups by having students fill out a form giving information about their schedules.