title: Why isn't my overloading < operator not working for STL sort
body: <p>I have this following code where I want to sort vector of string according to the last character of the string. I've done the following but the sorting is done by default rules.</p>
  
  <p>Here's the overloading &lt; part:</p>
  
  <pre><code>bool operator&lt;(const string &amp;s1, const string &amp;s2){
      return s1.at(s1.size() - 1) &lt; s2.at(s2.size() - 1);
  }
  </code></pre>
  
  <p>This is in main:</p>
  
  <pre><code>vector &lt;string&gt; nameList;
  int n;
  cin&gt;&gt;n;
  while(n--){
      string name;
      char str[100];
      cin&gt;&gt;str;
      name += str;
      nameList.push_back(name);
  }
  
  sort(nameList.begin(), nameList.end());
  for(int i = 0; i &lt; nameList.size(); i++)
      cout&lt;&lt;nameList.at(i)&lt;&lt;endl;
  </code></pre>
  
  <p>Code in ideone: <a href="http://ideone.com/OzCeV1" rel="nofollow">LINK</a></p>