Given a vector of pair of int and string something like this vector> . I need to sort them in a different fashion.
I want first element to be largest. Second element to be smallest and so on. Also if values are same then values must be shown in order in which they appear in original list.
Like say we have something like this : N=5 and here are 5 pairs :
10 bcd
2 abc
30 def
2 xyz
50 mn
Then output array should be : [mn,abc,def,xyz,bcd]
Explanation : Firstly 50 is largest so first element is "mn" then 2 is minimum but as "abc" come above "xyz" so take "abc" first. Then again maximum is 30 so "def",then minimum is 2 with "xyz" and then remaining "bcd" at end.
How can this be done with C++11 STL ? I know its otherwise not so difficult
Aucun commentaire:
Enregistrer un commentaire