
Why grouping goes wrong
Most courses form teams one of two ways: students pick their own, or staff sort them by hand. Self-selection rewards the already-connected and leaves newer or quieter students scrambling. Hand-sorting is slow and usually falls back on whatever data is easy to reach, like who is in which tutorial.
Both work most of the time. Both also leave a few people in groups that were never going to gel, and you rarely find out until the project is well underway.
Start from what a fair team needs
A team that works tends to have a mix of strengths, some overlapping availability, and at least a bit of say from the people in it. None of that is visible from a class list, so the only way to form on it is to ask for it first.
Balance, do not just sort
Fairness is not stacking all the strong students together, and it is not splitting friends up on principle. It is spreading skills and experience so no team is set up to fail, while respecting a reasonable number of the preferences students give you.