CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2000
    Location
    austin
    Posts
    101

    using STL's list::sort()

    how do i use STL's list's sort method (the one that takes a parameter). say for instance, i have code like this:

    list<MyClass*> myList;

    and i want to sort it. this is what i'm thinking of doing, but don't know if it is correct:

    bool LessThan(const MyClass*& lhs, const MyClass*& rhs) {
    return (*lhs) < (*rhs);
    }

    myList.sort(LessThan);

    will that work? is that how it is suppose to work? what is the function declaration suppose to look like that you pass to sort()?

    thank you very much

    -christopher bottaro
    cjb@cs.utexas.edu

  2. #2
    Join Date
    Feb 2001
    Location
    Sydney, Australia
    Posts
    1,909

    Re: using STL's list::sort()

    http://groups.yahoo.com/group/cpptips/message/259

    Please - rate answer if it helped you
    It gives me inspiration when I see myself in the top list =)

    Best regards,

    -----------
    Igor Soukhov (Brainbench/Tekmetrics ID:50759)
    igor@soukhov.com | ICQ:57404554 | http://soukhov.com

    Member of Russian Software Developer Network http://rsdn.ru
    Best regards,
    Igor Sukhov

    www.sukhov.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured