title: c++ custom compare function for std::sort()
body: <p>I want to create custom compare function for std::sort(), to sort some key-value pairs std::pair</p>
  
  <p>Here is my function</p>
  
  <pre><code> template &lt;typename K, typename V&gt;
   int comparePairs(const void* left, const void* right){
          if((((pair&lt;K,V&gt;*)left)-&gt;first) &lt;= (((pair&lt;K,V&gt;*)right)-&gt;first))
              return 1;
          else 
              return -1;
      }
  </code></pre>
  
  <p>Then, inside some class I have vector of pairs class member:</p>
  
  <pre><code>vector&lt;pair&lt;K,V&gt;&gt; items;  
  </code></pre>
  
  <p>And some method for sort this vector by keys, using std::sort()</p>
  
  <pre><code>std::sort(items.begin(), items.end(), comparePairs&lt;K,V&gt;);
  </code></pre>
  
  <p>I have compilation errors within , which said </p>
  
  <blockquote>
    <p>"cannot convert parameter number from 'std::pair&lt;_Ty1,_Ty2>' to 'const
    void*'"</p>
  </blockquote>
  
  <p>. What is a mistake?</p>