C++ Easiest Way to sort and read this file? : <p>This file seems a bit... awkward to manage. I need to sort the file by the highest score and here is a small sample of the file at hand:</p>

<pre><code>reece 0 
john 5
alex 2
</code></pre>

<p>Just a few bits of the data. Basically I need it sorted in the following arrangement and then wrote back to the original file:</p>

<pre><code>john 5
alex 2
reece 0
</code></pre>

<p>This also needs to be possible with an infinite amount of data (not inf but you understand what I mean). I have tried this:</p>

<pre><code>void read() {
    vector&lt;string&gt; arr;
    string a, b;
    ifstream file1;
    file1.open("Scores.txt", ios::out);
    int count = 0;
    while (file1 &gt;&gt; a &gt;&gt; b) {
        string toVec = a + b;
        arr.push_back(toVec);
        count++;
    }
    for (int outLoop = 0; outLoop &lt; count; outLoop++) cout &lt;&lt; arr[outLoop];
}
</code></pre>

<p>Now this reads from the file and put them into a vector but I don't know what to do from that point. The cout just shows this:</p>

<pre><code>reece0john5alex2
</code></pre>

<p>How would I go about splitting that up and sorting it?</p>
