title: Sorting a vector<Struct> alphabetically
body: <p>I have a <code>std::vector&lt;Word&gt; data</code> that is off of the struct below:</p>
  
  <pre><code>struct Word
  {
      std::string word;
      int line_number;
  };
  </code></pre>
  
  <p>I have read in words from a file and pushed it in to my vector storing the words in the string above along with the line number that the word appears on. Now I need to sort the words alphabetically and I attempt the following:</p>
  
  <pre><code>    std::sort(data.begin(), data.end());
  </code></pre>
  
  <p>However when I try to compile the following I get a crazy long list of errors. I believe this is due to the sort algorithm trying to compare the vector.begin() to vector.end() but it doesn't know how to evaluate the struct word to another struct word.</p>
  
  <p>However neither do I. I am stumped on how to compare the string contained with the structs in the vector.</p>