Why aren't passengers sorted before embarking?
Many airlines do, to a degree.
That's why airliners are often boarded in sections (for example row 1-10, then 11-15, etc.).
Problem is many of the passengers don't listen to instructions, and rush the boarding agent the moment the lights go on indicating boarding has started, in part because they're afraid there won't be space for their 4 bags in the cabin, each of them oversized, if they're not the first on board.

And THAT's the real problem, many airlines not being rigorous about enforcing cabin luggage allowances and pushing people with excess to the back of the line and having them gate check (at additional fees) those bags consistently.