'How to sort a multimap by value being from a struct?

I have a multimap that contains a tuple as key and struct as value.
After updating the value of one of the keys, I want to sort the multimap in order to be by DESC.

Here's an example:

#include <iostream>
#include <string>
#include <map>
#include <cstring>

typedef struct player
{
    player(int position, std::string name, int points) : position(position), playerName(name), points(points) {}

    int             position; // The position where the player is [like scoreboard]
    std::string     playerName; // Player's name
    int             points; // How many points
} PlayerStruct;

typedef std::multimap<std::tuple<int, int, int>, PlayerStruct> PlayerMap;

int main()
{    
    PlayerMap mPlayerMap;

    // Inserting random data for the test
    mPlayerMap.insert(std::make_pair(std::make_tuple(0, 0, 0), PlayerStruct(0, "player1", 30)));
    mPlayerMap.insert(std::make_pair(std::make_tuple(0, 0, 0), PlayerStruct(1, "player2", 20)));
    mPlayerMap.insert(std::make_pair(std::make_tuple(0, 0, 0), PlayerStruct(2, "player3", 10)));

    // Here we going to update the player3
    for (auto it = mPlayerMap.begin(); it != mPlayerMap.end(); ++it)
    {
        const PlayerStruct& players = it->second; // Gets the player struct info
        if (strcmp(players.playerName.c_str(), "player3") == 0) // If the player's name is the same as "player3"
            it->second = PlayerStruct(players.position, "player4", 50); // updates the value to 50 and the player name

        std::cout << "position: " << players.position << ", name: " << players.playerName << ", points: " << players.points << std::endl;
    }
}

Expected result:

position: 0, name: player4, points: 50 
position: 1, name: player1, points: 30
position: 2, name: player2, points: 20

Actual result:

position: 0, name: player1, points: 30
position: 1, name: player2, points: 20
position: 2, name: player4, points: 50

I searched and find something like std::sort or std::find_if but nothing worked.

c++


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source