a question about STL sort
-
struct A{ public: CString str1; CString str2; COleDateTimeSpan vdTime; long nNum; }; typedef std::list aList; ......//add some A Type to aList can i sort the 'aList' by the nNum? How to do with it?
Add a suitable comparison operator to
A
:struct A
{
...
bool operator<(const A& r) const
{
return nNum<r.nNum;
}
}and then just use
std::list::sort
. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
struct A{ public: CString str1; CString str2; COleDateTimeSpan vdTime; long nNum; }; typedef std::list aList; ......//add some A Type to aList can i sort the 'aList' by the nNum? How to do with it?
I cover this at length in my article on functors. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002