In my current project (homework), I am storing a pair of values in a map. The ID is an integer, and the value is a string (name of a movie) and an integer (rating of the movie on a 1-5 scale). I need to get the elements into the map in a certain order (least number of vowels in the movie name to greatest, and if they have the same, use string comparison operator <). What I want to know is: how do I compare the strings if there is already one in the map at the position?
Here is the relevant code:

vowelcnt = vowelcnt*10000;
		string temp;
		//temp = mmap[second.first]; //I need this to compare the values of the strings. I don't know how to get this from the map
		if (mmap.find(vowelcnt)==mmap.end())//if mmap does not contain the ID of vowelcnt
		{
			mmap.insert(pair<int, pair<string, int> >(vowelcnt,make_pair(movie,rating)));
		}
		else//if a string name with that number of vowels is currently in mmap
		{
			while(!(mmap.find(vowelcnt)==mmap.end()))//while loop "while there is an id with this number in it"
			{
				if (temp < movie)
				{
					vowelcnt = vowelcnt-1;//sets the tempid to the next empty space before
				}
				else //if temp > movie, since temp = movie cannot happen because it would have landed in the "if" statement
				{
					vowelcnt = vowelcnt+1;//sets the tempid to the next empty space after
				}
			}
			mmap.insert(pair<int, pair<string,int> >(vowelcnt,make_pair(movie,rating)));
		}

If anyone could help me understand how to get this list sorted properly, that would be great.

You will have to create a string comparison function or better a functor (if you have yet learned what a functor/function object is). And you have to use that for doing your comparison and not the standard string comparison.

Be a part of the DaniWeb community

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