// Define a structure, PS, and some related functions for holding // pairs of strings #include using namespace std; struct PS : pair { PS() : pair(string(), string()) { } PS(const string& s) : pair(s, s) { sort(first.begin(), first.end()); } operator string() const { return second; } }; struct FirstLess : binary_function { bool operator()(const PS& p, const PS& q) const { return p.first < q.first; } } firstLess; struct FirstEqual : binary_function { bool operator()(const PS& p, const PS& q) const { return p.first == q.first; } } firstEqual;