Here is a flimsy answer. The number of times a specific name appears among all names beginning with the same letter should be compared to the number of names beginning with that letter that should be in each section before assigning a section number. :
=LET(names,E5:E883,
rows,ROWS(names),
sections,12,
seq,SEQUENCE(rows,1,0),
startrow,XLOOKUP(LEFT(names,1)&"*",names,seq,,2),
counts,COUNTIF(names,LEFT(names,1)&"*"),
countspersection,counts/sections,
occurrence,seq-startrow,
section,QUOTIENT(occurrence+0.5,countspersection),
section)
Then sort on the assigned section number:
=LET(names,E5:E883,
rows,ROWS(names),
sections,12,
seq,SEQUENCE(rows,1,0),
startrow,XLOOKUP(LEFT(names,1)&"*",names,seq,,2),
counts,COUNTIF(names,LEFT(names,1)&"*"),
countspersection,counts/sections,
occurrence,seq-startrow,
section,QUOTIENT(occurrence+0.5,countspersection),
SORTBY(names,section,1,names,1))
The size of each section will vary depending on how many of the numbers assigned are underestimates and how many overestimates compared to the theoretical value (for example, there should be 7.4 A's in each section, but in practice, there can only be 7 or 8). This is because the number of students can only be a whole number. I've done some research on this, and the results show that the group sizes are as follows:
It's quite difficult to get both the group sizes and numbers per letter exactly right - you would need an iterative method to take this further I think.