So I have a program that reads through a file and gets the largest words by using a map with an int as the key and a vector as value. I need to print out the largest words but have a problem with the sorting. Whereas the output should be Copyright, Publishin, Universal, blueprint I get :blueprint, Copyright, Universal, Publishin
How can I fix this? Do vectors not sort uppercase AND lowercase? Here's what I have so far:
string temp;
stringstream ss(line);
while(ss >> temp){
int wordlength = temp.length();
wordit = wordbycount.find(wordlength);
if(wordit != wordbycount.end()){
vector<string> arrayofLongest= wordit->second;
std::vector<string>::iterator iterator1 = find(arrayofLongest.begin(), arrayofLongest.end(), temp);
if(iterator1 == arrayofLongest.end())
{wordit->second.push_back(temp);} }
else{
wordbycount[wordlength] = {temp};
} } }
Aucun commentaire:
Enregistrer un commentaire