Hogwart is a stupid school because Sorting Hat is truly a stupid, stupid thing.
"Hey, let's separate all the kids according to their most defining personality since you know, how your personality is in the young age clearly dictates the way you live your life in its entirety, and no, cohesiveness is not good so why not we adhere to a system that incredibly promotes inclusiveness and don't let *that* type of kid to mingle with *this* type of kid? Especially nice with that one particular branch where we like, put *all* the bad evil kids in so that they can only strengthen their evilness by interacting daily with their fellow like-mindedness evil overlord potential kids."
I don't think the Sorting Hat really reads your mind and uses a snapshot of one underdeveloped, temporary stage of your life to decide your entire future, I think it looks into your mind as a way to read your future. It can see "everything" in your head, all you are is laid bare, and there are four paths ahead of you, and it can see enough to know how you'll respond to each of them. Will you thrive, fail, or just get by?
And then, the Hat doesn't ignore who you are in the moment. Harry had a bad impression of Slytherin, and the Hat tested him, offering him greatness, but when Harry refused to take that power, he got sent to Gryffindor. Neville, on the other hand, refused to go to Gryffindor. He had low self-esteem and insisted that he wasn't good enough for Gryffindor, he belonged in Hufflepuff, and the Hat insisted that his "fight" to go to Hufflepuff was the "fight" that proved he belonged in Gryffindor. And it was right, Neville became a badass.
And the Hat doesn't judge. If you really are a Slytherin, if that's what's right
for you, then it'll send you there so you can grow and be the best that you can be. Problem is, there are a lot of assholes in the world.
As for inclusiveness and mingling, sorting takes a group of scared, lonely little kids and gives them a place to belong. None are left out or lost in the crowd, because every one of those kids has been recruited into a group of like-minded individuals. By dividing the students, they bring some of them closer together. And there are shared classes. How many times did you see Harry in the same class as Draco? It's because on X-day Gryffindor shares a class with Slytherin. On Y-day they share a class with Ravenclaw. On Z, it's Hufflepuff. Plenty of room to get to know each other.
Snape and Lily were BFFs, until Snape called her a mudblood. Ginny and Luna became BFFs in their first year. Luna dated both Harry and Neville. Harry dated Cho. There are clearly no rules against mingling.