Standard library sort and user defined types
<p>If I want to sort a vector of a UDT by one of two types of variables it holds, is it possible for the standard library sort to do this or do I need to write my own sort function.</p>

<p>For example if you had</p>

<pre><code>struct MyType{
 int a;
 int b;
};

vector&lt;MyType&gt; moo;

// do stuff that pushes data back into moo

sort(moo.begin(), moo.end()) // but sort it by lowest to highest for a, not b
</code></pre>

<p>So is this possible using the stdlib sort? Thanks.</p>
