#include #include using namespace std; // each class here is for building function objects (functors) // each comparison function returns true if the first parameter comes // BEFORE the second parameter in the ordering, false otherwise class LengthCompare { public: bool operator() (string s1, string s2) { return (s1.length() < s2.length()); }; }; class AlphabeticCompare { public: bool operator() (string s1, string s2) { string x = s1; // make copies string y = s2; for (int i = 0; i < x.length(); i++) x[i] = tolower(x[i]); for (int i = 0; i < y.length(); i++) y[i] = tolower(y[i]); return (x < y); }; }; class LastLetterCompare { public: bool operator() (string s1, string s2) { return (s1[s1.length()-1] < s2[s2.length()-1]); }; };