954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Map Copying

Is there a way to move data from one map to another without it being re-sorted? Ex: I have a map of <int, pair<string, int> where the key is the number of vowels in the string (int) and the pair contains a moviename as string and rating as int (multiple entries for each moviename). I want to move this data to two maps; one with the moviename as key and total of all ratings as value, and one with the moviename as key and the number of all ratings as value. These should stay sorted in the same order (lowest number of vowels to greatest). Then the data should be outputted as moviename, number of reviews, average review score.
I already have the program work to sort the first list properly. The list contents make it into the second list, and get outputted properly, but not in the right order.
If anyone can help, that would be great.

iamthesgt
Junior Poster
107 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

No, the map sorts on the key. If you change the key then the sort order changes. You state that the key is the movie name for both maps, so the order should not be different.

If you want a different sort criteria, then your map type should specify one as a template argument...

Hope this helps.

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

How do you specify a different sort criteria as a template argument?

iamthesgt
Junior Poster
107 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: