Sorting map in C++

Правка en1, от arham___khan, 2021-07-24 07:43:28

If I have a map<string,pair<int,int>> and I want to sort it in three different ways. 1.Sort by key. 2.Sort by value of first element in the pair. 3.Sort by value of second element in the pair.

Example : if mp [ {a,{9,7}} {y,{2,5}} {g,{3,1}} {i,{6,6}} {e,{1,2}} ]

1.Sort by key:
2.Sort by value of first element in the pair:
3.Sort by value of second element in the pair:

How to implement the above-mentioned three ways of sorting?

Теги #std::map, #sorting

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский arham___khan 2021-07-24 07:43:28 740 Initial revision (published)