Pass a new comparison method to list.sort()

Hi,

I am a beginner to C++. I'd like to use list::sort() with a custom sort method.
I read from the sort() doc, that we can pass a custom method.
I tried to do it myself as mentionned in the example code on sort() method doc.

But when I try to compile my code I am facing a problem that I don't you how to solve, though I am sure it is quite easy to solve :)

Here is the error:

Histogram.cc: In member function 'bool Histogram::_sortByStart()':
Histogram.cc:351: error: no matching function for call to 'std::list<Seq*, std::allocator<Seq*> >::sort(<unresolved overloaded function type>)'
/usr/include/c++/4.2/bits/list.tcc:271: note: candidates are: void std::list<_Tp, _Alloc>::sort() [with _Tp = Seq*, _Alloc = std::allocator<Seq*>]
/usr/include/c++/4.2/bits/list.tcc:348: note: void std::list<_Tp, _Alloc>::sort(_StrictWeakOrdering) [with _StrictWeakOrdering = bool (Histogram::*)(Seq*, Seq*), _Tp = Seq*, _Alloc = std::allocator<Seq*>]


And here my code :

bool Histogram::_byStart(Seq* s, Seq* e) {
return (s->get_start() < e->get_start());
}


bool Histogram::_sortByStart() {

map<string, list<Seq*> >::iterator it;
cout << "Entering _sortByStart() ..." << endl;

for(it = this->_get_Seqs()->begin();
it != this->_get_Seqs()->end();
it++) {

//Don't bother with empty list
if(it->second.empty())
continue;

string id = it->first;
this->_get_Seqs()->find(id)->second.sort(_byStart);
}
this->_seq_sorted = true;
return this->_is_sorted();

}


Thanks in advance for any answer.

Regards
Topic archived. No new replies allowed.