I'm using a multiset object to sort a group of strings that I'm passing into it(using the default alphabetical ordering that it provides). My issue is that it is not sorting the strings like it is supposed to. I know it should work because I was using one in another part of my code to do the same thing, and I had no issues. Args is a string with a bunch of words in it, and I'm stripping out the words individually to be sorted by the multiset. Here is the function in which I'm using it in:
void
SimpleCommand::sortAndInsertArgument(char * args){
//cout << args;
char * word;
multiset<string> sortedArgs;
word = strtok (args," \t\n");
while(word!=NULL){
sortedArgs.insert(strdup(word));
word = strtok (NULL," \t\n");
}
multiset<string>::iterator it;
for(it=sortedArgs.begin();it!=sortedArgs.end();it++){
string str = *it;
const char * charStr = str.c_str();
Command::_currentSimpleCommand->insertArgument(strdup(charStr));
}
}