title: Ordering output of C++ std::set
body: <p>I want to list the output of my set in alphabetical order. Below is an attempt at getting to this, but it seems slow / inefficient and I haven't even finished it yet.</p>
  
  <pre><code>void ordered(ostream &amp;os) {
      bool inserted = false;
      for (objects::iterator i = begin(); i != end(); ) {
          for (objects::iterator x = begin(); x != end(); ++x) {
              if((**i) &lt; (**x)) { //overloaded and works
                  os &lt;&lt; **i &lt;&lt; endl;
                  inserted = true;
                  break;
              }
          }
          if(inserted) {
              ++i;
          }
      }
  }
  </code></pre>
  
  <p>Clearly this will only output objects that come after the first object alphabetically.</p>
  
  <p>I also considered moving the objects from a set into another container but it still seems inefficient.</p>