title: How to sort std::list of pairs by key?
body: <p>I would like to sort a <code>std::list&lt;std::pair&lt;string, int&gt;&gt;</code> by the <em>key</em> as well as by the <em>value</em> in two separate functions. </p>
  
  <p>I am getting an error that says:</p>
  
  <pre><code>error: reference to non-static member function must be called
      sort(test.begin(), test.end(), sortByVal);
  </code></pre>
  
  <p>The code</p>
  
  <pre><code>class Test 
  {
      std::list&lt;pair&lt;std::string, int&gt;&gt; test;
  
  public:
      void sortbykey()
      {
          sort(test.begin(), test.end(), sortByVal);
      }
  
      bool sortByVal(const std::pair&lt;std::string, int&gt;&amp; a, const std::pair&lt;std::string, int&gt;&amp; b)
      {
          return (a.first &lt; b.first);
      }
  };
  
  </code></pre>