title: Sorting with a list iterator
body: <p><strong>Problem:</strong> I have a list of objects I want to render every cycle, but I would like to render them in the order of their y- positions which is variable. </p>
  
  <p>Here are my list declarations...</p>
  
  <pre><code>std::list&lt;Object *&gt; objects;
  std::list&lt;Object *&gt;::iterator iter;
  std::list&lt;Object *&gt;::iterator iter2;
  </code></pre>
  
  <p>Here is what I have so far...</p>
  
  <pre><code>for(iter = objects.begin(); iter != objects.end(); ++iter) //goes through my objs
     if((*iter)-&gt;GetID() == PLAYER || (*iter)-&gt;GetID() == ENEMY) //only part of the list
        for(iter2 = iter; iter2 != objects.end(); ++iter2) //goes through the same objs
           if((*iter2)-&gt;GetID() == PLAYER || (*iter2)-&gt;GetID() == ENEMY) //same as line 2
              if((*iter)-&gt;GetY() &gt; (*iter2)-&gt;GetY())
  </code></pre>
  
  <p>I want to render the objects in decreasing order of their y-values. I guess my real question is how I would sort this list.</p>