Sorting a Vector with std::sort
<p>I got a vector containing pairs. My pairs have template parameters. </p>

<pre><code>std::vector&lt;std::pair&lt;T1, T2&gt; &gt; myVector;
</code></pre>

<p>I would like to sort myVector by the pairs second data tag, so by the "value"(T2), not the "key"(T1).
I saw <a href="http://www.cplusplus.com/reference/algorithm/sort/" rel="nofollow">here</a> that i can use this sweet method:</p>

<pre><code>std::sort(myVector.begin(), myVector.end(), mySortingFunc);
</code></pre>

<p>and this is my sortFunc:</p>

<pre><code>bool mySortingFunc (std::pair&lt;T1, T2&gt; pair1,   std::pair&lt;T1, T2&gt; pair2){ 
     return (pair1.second&lt;pair2.second); 
}
</code></pre>

<p>and its not compiling, throwing me 10 kilometers long error. (i use g++)
Any advice how should i do this?</p>

<ul>
<li>E D I T:</li>
</ul>

<p>Actual code:</p>

<pre><code>template&lt;typename T1, typename T2&gt;
class OrderedMMap
{

std::vector&lt;std::pair&lt;T1, T2&gt; &gt; myVector;

public:

bool sortFunc (std::pair&lt;T1, T2&gt; pair1,   std::pair&lt;T1, T2&gt; pair2) { 

    return (pair1.second&lt;pair2.second); 
}

void sortIt()
{
    std::sort(myVector.begin(), myVector.end(), sortFunc);
}
};
</code></pre>
