Earlier quoted context omitted.
What you call "most and least gifted" is in my opinion better described as "most and least privileged". And coeducation of students of different levels of privilege just seems like a good thing, nothing that needs to be dealt with.
The issue, in my experience, is that you have to compromise somewhere. That means either leaving the higher performers to be bored, or leaving the lower performers not achieving the minimum. Neither seems like a desirable outcome.
Personal experience: I had a great math teacher in mid school; he gathered the best students from the 5 classes in that year in one class and he set the baseline quite high. For the last 2 years half of our class was taking the prizes at all the inter-school competitions in the city and a few of us from the nationals. Most of that class went to the best high schools in the city and most are today great doctors (medical) or scientists. Imagine that did not happen in mid-school and everybody would be an average Joe - that is a loss for humanity, not just for us.
Try to read Ender's Game (the book, the movie is terrible). This is very tough, but if you need great people you can help by creating the conditions to grow them. How many Einsteins wasted their lives achieving nothing and how earlier curing diseases and improving technologies was possible if that waste did not happen?
The compromise is to waste the resources that we have in the name of equality; we cannot make everyone smart, we only can make them all stupid, so let's do equality.