title: How to realize sequent addition of elements to vector, sorting them before to insert?
body: <p>I tried to write programm inserting elements into a vector, sorting them in alphabetical order. The element before to be inserted compares with another ones till it more than element already inserted. After it was assumed to add compared element using <code>.insert()</code>. I want to realize it without using sort algorithmes.</p>
  
  <pre><code>std::string name;
  std::vector&lt;std::string&gt; students;
  std::vector&lt;std::string&gt;::iterator beg = students.begin();
    while (std::cin&gt;&gt;name){
          for (std::vector&lt;std::string&gt;::iterator e = students.end() ; beg !=e ; ) {
              if (!name.compare(*beg))
              {
                  students.insert(beg, name);
                  break;
              }
              else
                  beg++;      
           }
      }
  </code></pre>
  
  <p>To avoid invalidate of iterator pointed to the last element I renew it each iteration. 
  The problem is after this part of code I check the vector but it's empty.</p>