The fact that you're using tolower at all suggests to me that you're looking for a case-insensitive sort of those strings. If this is the case all you do is:
Code:
#include <cctype> // for toupper
#include <string>
#include <algorithm>
using namespace std;
bool operator()(string left, string right) {
transform(left.begin(), left.end(), left.begin(), (int(*)(int)) toupper);
transform(right.begin(), right.end(), right.begin(), (int(*)(int)) toupper);
return left < right;
}
Now if this is a struct then you wont want to modify the contents of those strings when comparing them, so be sure you make a copy first in that case.