shift operation in linked list
<p>name<br />
played games<br />
score</p>

<p>Deep<br />
5<br />
540 (head)</p>

<p>Peter<br />
34<br />
455</p>

<p>Avijit<br />
2<br />
430</p>

<p>Pekka<br />
4<br />
310 (tail)</p>

<p>For the above linked list of player list, I want to sort list in ascending order when Avijit gets higher score than Peter. So its a shift operation in linked list. Can anyone help me to find out the problem in code below to do this operation. And any solution?
Thanks.</p>

<pre><code>void Player::update_statistics(int last_game_point)
{
    player_ptr currPtr = head; // Moving pointer
    player_ptr prevPtr = NULL; // Pointer to node before *currPtr
    //player_ptr head;                //  class variable in Player class
    //player_ptr selected_player;     //  class variable in Player class
    //player_ptr previous_player;     //  class variable in Player class 

    // update selected player's data
    cout&lt;&lt;++(selected_player-&gt;played_games);  // increase by 1 for last game
    selected_player-&gt;total_point=(selected_player-&gt;total_point)+last_game_point;

    if ((selected_player!=head) &amp;&amp; (previous_player-&gt;total_point &lt; selected_player-&gt;total_point)){
        previous_player-&gt;link = selected_player-&gt;link;

        // search for appropriate position
        while (currPtr-&gt;total_point &gt; selected_player-&gt;total_point){
            prevPtr = currPtr;
            currPtr = currPtr-&gt;link;
        }

        if (currPtr==head)
            selected_player-&gt;link=head;
            head=selected_player-&gt;link;
        }
        else {
            previous_player-&gt;link=selected_player;
            selected_player-&gt;link=currPtr;
        }
}
</code></pre>
