Sweep & prune broadphase algorithm My game engine uses the following broadphase collision detection algorithm:
internal void SweepAndPrune()
{
    // First: order all objects from left to right on the x-axis:
    IOrderedEnumerable&lt;GameObject&gt; axisList = _gameObjects.OrderBy(x =&gt; x.LeftRightMost.X);

    // loop through all objects:
    for(int i = 0; i &lt; axisList.Count(); i++)
    {
        // For each object, iterate over all the subsequent objects in the list
        // and find out if there are overlaps on the x-axis:
        for(int j = i+1; j &lt; axisList.Count(); j++)
        {
            GameObject a = axisList.ElementAt(i);
            GameObject b = axisList.ElementAt(j);
            if(b.Left &gt; a.Right)
            {
                // if their is no overlap, then the rest will not overlap as well.
                // might as well stop the inner loop here:
                break;
            }
            // if there is an overlap, add A to B's list 
            // and B to A's list of potential collisions.
            // [every object's list of collision candidates is 
            // cleared before the next frame]
            a._collisionCandidates.Add(b);
            b._collisionCandidates.Add(a);
        }
    }
}

The problem is, this algorithm slows down the performance by a lot if there are &gt; 50 objects on screen.
Also, the list of GameObject instances (_gameObjects) needs to get sorted another time per frame because I need to order the objects by their distances from the camera (background objects need to get rendered first because of transparency!).
Is there anything I can do to speed things up?
An IEnumerable (and IOrderedEnumerable) represents a question, not an answer. axisList is not really a list -- it is a question asking &quot;What is the sequence of elements from _gameObjects ordered by X value?&quot;. So every time you do this:
            GameObject a = axisList.ElementAt(i);
            GameObject b = axisList.ElementAt(j);

You are answering the question &quot;What is the ith element in that ordering&quot;. Which means it needs to re-order the sequence on every iteration! Your outer loop ends up being hugely expensive (O(n^3 log(n)) if my math checks out); you certainly don't need to do that.
You should cache the result of the ordering and re-use it in your loop. Change this
IOrderedEnumerable&lt;GameObject&gt; axisList = _gameObjects.OrderBy(x =&gt; x.LeftRightMost.X);

to this:
var orderedByX = _gameObjects.OrderBy(x =&gt; x.LeftRightMost.X).ToList();

.ToList() will evaluate the OrderBy query and return a flattened &quot;answer&quot; that you can keep reusing, and as a bonus it has O(1) lookup so ElementAt is fast -- you could even change ElementAt(i) to [i] to make that more clear.