C++ How to do 2 Sort and merge result into 1
<p>Parent Class:</p>

<pre><code>Character
</code></pre>

<p>Sub class:</p>

<pre><code>Elf
Human
</code></pre>

<p>I have a variable which is</p>

<pre><code>int myScore;
string myType;
</code></pre>

<p>so what i did was to sort by myType then sort by ascending score</p>

<p>means if i got record like this</p>

<pre><code>[1] Human, 99
[2] Elf, 91
[3] Elf, 99
[4] Human, 99
</code></pre>

<p>If sort it will be</p>

<pre><code>[1] Human, 90 
[2] Human, 99
[3] Elf, 91
[4] Elf, 99
</code></pre>

<p>I heard before the merge function that can merge 2 sort into 1.</p>

<p>But how do i use it.</p>

<p>What i did for now is </p>

<p>At character.cpp</p>

<pre><code>struct sort_by_score
{
    static bool operator()(Character* x, Character* y)
    {
        return x-&gt;getScore() &lt; y-&gt;getScore();
    }
};
</code></pre>

<p>At main.cpp</p>

<p>I did this</p>

<pre><code>int main()
{
Character *chara[100];
vector&lt;Character*&gt; sortVector;

//some input of value here.. assuming now got 4 pointers to object, 2 human 2 elf. 

sortVector.clear();
sortVector.assign(chara,chara + characterCounter);

//here i got question on how to sort by Human Then Elf

//2nd sort is sort by score
sort(sortVector.begin(), sortVector.end(), sort_by_score());

for (int i=0;i&lt;characterCounter;i++)
{
cout &lt;&lt; sortVector.toDisplay() &lt;&lt; endl;
}

return 0;
}
</code></pre>

<p><strong>Thanks for all help!!</strong></p>
