Hi! i've some object in a 2d space. I want to make collision detection, so in teory i have to test each one with all other objects.
Obviously this is too expensive.. i was wondering how can one optimize the control.
Are there solutions to this?

I've had this idea, but i don't know if it's the best (probably not ):
I could keep all objects sorted by one coordinate (for example X), and then check each object only with some neighbours.. For example i could check in each "direction" until i find an object that is far enought in the X coordinate to be surely not colliding.