My public middle-and-high schools were attended by a very wide quality-range of students, and they did an excellent job segregating students within the school into different classes according to academic ability.
There was mobility in that students who performed very well in the B-level classes were able to join A-level classes in subsequent semesters while poorly performing students were advised to move downward. Most of the subjects had three ability levels (A, B, G). There were even some students who would excel in one subject and take AP english or history while remaining at a more normal level in the STEM subjects.
Most importantly, I am convinced that the A-level students at my highschool received just about as good an education as they could find at any public school in the country. At the same time that G level and some B-level students were preparing to graduate and not go to college, most of my classmates in the A group were graduating having completed college-freshman-or-sophomore-level calculus and many were receiving acceptance letters from Ivy-league universities.
I don't know for sure whether or not this type of arrangement is common, but it seems to me like it shows that having a mixture of academic abilities in the same neighborhood need not be a disaster.