I am trying to sort an array of strings. I was doing some tests and I found something that I did not expect. I can not explain it.
if ("test" < "paul")
{
cout << "test is less than paul" << endl;
}
Why is "test" less than "paul"? 'p' has a lower ASCII value than 't'. It also comes before p in the alphabet. The string length is also the same in both cases.
I am using swap() to sort the array in alphabetical order(well trying to). I can not use sort(), I need to use swap.
update: in the above example I used a pointer, but this is my actual code.
DynamicArray<string> sectionName; //declaration
swap(alreadySeen[i].sectionName[j],alreadySeen[i].sectionName[i]); //usage
This is obviously not the complete code, don't want to get lost in the details