sorting std::list with function predicate
From: matthias_k (nospam_at_digitalraid.com)
Date: 01/23/05
- Next message: matthias_k: "Re: sorting std::list with function predicate"
- Previous message: Karthik Kumar: "Re: Correct C++ tutorial part 4 "Decisions & conditions" available (Windows, mingw/msvc/std)"
- Next in thread: matthias_k: "Re: sorting std::list with function predicate"
- Reply: matthias_k: "Re: sorting std::list with function predicate"
- Reply: Karthik Kumar: "Re: sorting std::list with function predicate"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 23 Jan 2005 11:50:21 +0100
Hi,
I need to sort elements of a std::list using a function predicate,
something like:
bool predicate( const& M m1, const& M m2 ) {
return m1.somedata < m2.somedata;
}
I tried to call std::list::sort with such a predicate but that doesn't work:
mylist.sort( predicate ); // error, no matching function call
So since I must not call std::sort on a list, how can I sort it in a way
other than the standard operator< of its element does?
I need to do it with predicates, because I need to sort the list with
different sorting criterions, depending on the situation.
Regards,
Matthias
- Next message: matthias_k: "Re: sorting std::list with function predicate"
- Previous message: Karthik Kumar: "Re: Correct C++ tutorial part 4 "Decisions & conditions" available (Windows, mingw/msvc/std)"
- Next in thread: matthias_k: "Re: sorting std::list with function predicate"
- Reply: matthias_k: "Re: sorting std::list with function predicate"
- Reply: Karthik Kumar: "Re: sorting std::list with function predicate"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|