 <p>Could you be a little bit more specific in that what you want to achieve ? you can provide your own comparison operator when sorting</p> <pre><code> template &lt;class RandomAccessIterator, class Compare&gt; void sort ( RandomAccessIterator first, RandomAccessIterator last, Compare comp ); </code></pre> <p>For more info read the manual <a href="http://www.cplusplus.com/reference/algorithm/sort/" rel="nofollow">http://www.cplusplus.com/reference/algorithm/sort/</a></p>