STL Questions
1. Sorting a vector of custom objects a)Using operator() struct MyStruct { int key; std::string str; MyStruct(int k, int s) : key(k), str(s) {} }; struct less_than{ inline bool operator()(const MyStruct &s1, const MyStruct &b) { return s1.key<s2.key; } }; std::vector<MyStruct> vec; vec.push_back(MyStruct(4, "a")); ...