C
cylin
Dear all,
If I declared a map<int,string> MapA;
How can I sort MapA by its data,i.e. string.
for example:
map<int,string> MapA;
MapA[1]=string("ccc");
MapA[2]=string("bbb");
MapA[3]=string("ddd");
MapA[4]=string("aaa");
I want to the result is (4,"aaa"),(2,"bbb"),(1,"ccc"),(3,"ddd");
Because key of a stl map is always ordered.
Is it possible to use sort(MapA.begin(),MapA.end(),?????) ?
Another is how to use merge() with 2 stl maps?
Thanks for your help.
Regards,
cylin.
If I declared a map<int,string> MapA;
How can I sort MapA by its data,i.e. string.
for example:
map<int,string> MapA;
MapA[1]=string("ccc");
MapA[2]=string("bbb");
MapA[3]=string("ddd");
MapA[4]=string("aaa");
I want to the result is (4,"aaa"),(2,"bbb"),(1,"ccc"),(3,"ddd");
Because key of a stl map is always ordered.
Is it possible to use sort(MapA.begin(),MapA.end(),?????) ?
Another is how to use merge() with 2 stl maps?
Thanks for your help.
Regards,
cylin.