title: How to sort by Alphabetical in C++
body: <p>I've been trying to sort a vector of Employee's with a string data member called last name. I've tried several different ways, using the sort method of vector, trying to convert my vectors to list and using its sorting, I even tried using string compare and > operators as shown below:</p>
  
  <pre><code>    vector&lt;Employee&gt;sortE(vector&lt;Employee&gt;record)
  {
      for (unsigned int i = 0; i &lt; record.size() - 1; i++)
          if (record[i].getLastName() &gt; record[i+1].getLastName())
              swap(record[i], record[i + 1]);
      return record;
  }
  </code></pre>
  
  <p>I thought if I used the above method with the swap function, it would work. But maybe since swap is a string method and I'm doing it with Employees it won't swap properly? But I've also tried it with my own "swap" like below: </p>
  
  <pre><code>vector&lt;Employee&gt;sortE(vector&lt;Employee&gt;record)
  {
      Employee temp;
      for (unsigned int i = 0; i &lt; record.size() - 1; i++)
          if (record[i].getLastName() &gt; record[i + 1].getLastName())
          {
              temp = record[i];
              record[i] = record[i + 1];
              record[i + 1] = temp;
          }
  
      return record;
  }
  </code></pre>
  
  <p>Either way I can't seem to get it to work properly, any insight or help would be appreciated.</p>