But why sort at all?
Good question. Because I'm running into an issue if I dont! I guess there's again, a much simpler way to solve that, but that's my solution so far.
Take a look at followig example:
If I dont adjust the dx, dy values with the nearest obstacles first the Entity will get stuck at corners.
In the example the Entity is moving down left (hence dx and dy have the same negative value. Now if it slides
along the blue Obstacle it comes to the point (illustrated in the picture) where it's right at the edge of the red obstacle.
If I dont adjust dy with the nearsest obstacle first (the blue one) it could pick the red obstacle first. And if that happens
the code would set both dx and dy to 0, because the Entity intersects right at the edge and hence the Entity would get stuck.
By checking the nearest Obstacle first I prevent that because the blue Obstacle would have already set dy to 0 and the Entity
would have never intersected with the red Entity.
I really hope that wasn't too confusing... sorry