cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
sorting descending in a map of map
sorting descending in a map of map
Sep 12, 2019 at 10:21am
Sep 12, 2019 at 10:21am UTC
litusahoo
(13)
hi
i have a map in the below map of map, with sorting in descending, but the
mMap1.insert(pair<string,map<string,string>>("SC-20", m1)) is showing error.
How can this be done.
map<string, map<string, string>, greater<int>> mMap1;
map<string, string> m1;
m1.insert(make_pair("12", "6.5"));
m1.insert(make_pair("13", "6.6"));
m1.insert(make_pair("14", "6.9"));
mMap1.insert(pair<string,map<string,string>>("SC-20", m1));
With Regards
Sep 12, 2019 at 10:49am
Sep 12, 2019 at 10:49am UTC
coder777
(8449)
mMap1.insert(pair<string,map<string,string>>("SC-20", m1)) is showing error.
The reason is that
greater<
int
>
expects
int
while you provide
string
for comparison:
greater<
string
>
Sep 12, 2019 at 11:59am
Sep 12, 2019 at 11:59am UTC
litusahoo
(13)
Hi
Thank you very much, i am such a dumb.
Topic archived. No new replies allowed.