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.

Recommended Answers

All 2 Replies

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.