giving into the idea that the world is a sexist place
In my opinion the world is an extremely sexist place. Girls' schools are environments we can be free of that for a time, be valued for who we are, be ourselves and not have to put up with the sexism which is inherent in the world and commonplace in mixed schools from what I've read and heard first hand. The message is that your sex doesn't matter, you do, your interests and passions, your opinions. There are also often environments for discussing sexism and misogyny within society when the time is right (possibly not at every girls' school).
as I said ds is at an all boys school, and I actually think he is becoming less sexist rather than more.
This is heartening. My brothers are in all boys' education and certainly the elder of the two challenges his friends on sexism now but I've had some impact on this 
I wonder if the confidence girls receive is a result of being in selective education, that is knowing or being told they are best, rather than a result of not being around boys?
That may be part of it but I don't think this is the case. My school is an independent one but I feel it's being around so many intelligent girls which is what makes it so inspiring for me. I don't think we're told we're the best either - more that we should strive to be the best we can and follow our passions. Of course it's a huge privilege to be able to attend such a school though.
the horrible bullying that seems to be the modus operandi of teenage girls
Sorry to hear of your experience and I hope you're alright now. I do however hate this kind of statement which in my opinion is deeply misogynist. My school as I've posted is incredibly supportive with girls looking out for one another and supporting each other across friendship and year groups (and I know friends at other girls' schools who speak similarly of theirs). The camaraderie and support girls have for one another in all sorts of situations is so important and has helped me a great deal. I get enraged when people suggest teenage girls (of which I am one) are "horrible" or "bullying".