title: C++ Sorting vector of structs alphabetically
body: <p>I have this record management program I am building for an introductory programming course. Part of the code is the function <code>sortEmail</code> which is supposed to sort the vector recordList alphabetically and calls the <code>sortAlphabet</code> function. I'm getting an error on this line:<code>sort(recordList.begin(), recordList.end(), compareAlphabet);</code> that "sort was not declared in this scope." How can I fix this?</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;string&gt;
  using namespace std;
  struct Record
  {
      string name;
      string email;
  };
  
  bool compareAlphabet(const Record&amp; a, const Record&amp; b)
  {
      return a.name &lt; b.name;
  }
  
  sortEmail(vector&lt;Record&gt;&amp; recordList)
  {
      system("cls");
      sort(recordList.begin(), recordList.end(), compareAlphabet);
      cout&lt;&lt;"Name have been sorted alphabetically"&lt;&lt;endl;
      for (int i=0; i!=recordList.size(); i++)
      {
          cout&lt;&lt;recordList[i].name&lt;&lt;endl;
          cout&lt;&lt;recordList[i].email&lt;&lt;endl;
      }
      system("PAUSE");
      system("cls");  
  }
  </code></pre>