I have the class ElementList declared as so: #include namespace FUBAR { class Element { private: int _value; public: int Value() { return _value; } } class ElementList : public std::list { void sortByValues(); } } I wish to sort ElementList's members, which are Element *'s in order of the Value() property of Element. I am using MSVC 6.0, which is broken with respect to templates, so the standard answers around the Internet don't seem to apply. Also, the fact that I'm inheriting from the template class may admittedly make things harder. So the question is how to implement this function so that it calls Value() for each element and sorts on the return value of Value(): void ElementList::sortByValues() { ...??? ... } The following at least compiles in VC 6, but it sorts the list in descending order based on the value of the pointer, and in the debugger it doesn't call the compare function. I can't see what's wrong with it. #include #include #include using namespace std ; namespace FUBAR { class Element { protected: int _value; public: int Value() { return _value; } }; class ElementList : public std::list { void sortByValues(); }; } namespace std { struct greater_ElementPtr : public greater { public: bool operator()(FUBAR::Element* pl, FUBAR::Element* pr) { return pl->Value() > pr->Value(); } }; } void FUBAR::ElementList::sortByValues() { sort(greater_ElementPtr()); } I'd be happy to implement the sort with a qsort or some other algorithm that would work on std::list in MSVC 6.0, I just don't have enough experience with stl to figure this one out. Thanks!! -Kelly
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
Microsoft Visual C++ 6.0 (That it work with this Version is VERY important in this case.)