The students had 100% authority over how groups are formed, i.e. number of groups and who are in which group. The teachers had nothing to say in this.
The result is that:
1) it quickly became common knowledge who the slackers were (and who were the opposite).
2) nobody wanted to have the slackers in their group, so they were kind of ostracized and had to make their own group. They often ended up with the bad marks they deserve.
3) everybody learned that you had to do your homework/groupwork if you wanted to be part of a good group. It became a lot more difficult to get away with lame excuses for not having done what you promised. People really worked hard.
3b) If a group member didn't do their work, the other members could exclude the person from the group, and that person then had to make a project on their own, which is really really difficult. Again, the teachers had nothing to say in this, they could not veto an exclusion.
4) you ended up with a notion that your reputation had important consequences, just like in real life. Introverted people who did great work were popular group members.
5) Bonus: you learned to value different skills in people. Instead of wanting to be around people exactly like yourself, you learned that people who are (and think) different are very valuable for good projects.