Quote:
Originally Posted by Lucie365
I tried changing the compareTargets function to boolean as follows:
bool compareTargets(Target t1, Target t2) {
return (t1.m_score > t2.m_score)
}
This solved the problem. Apparently the sort function is looking for a true/false rather than -1/0/1. Both -1 and 1 were considered true (only 0 is considered false) so no sorting was actually being done.
|
You are right. I don't know about WindRiver C++ but apparently the standard Microsoft C++ sort function is expecting a bool compare function as well. I didn't realize this either. Long time ago in C, I believe the sort function in C runtime expects a compare function to return +1, 0 or -1. Apparently, C++ expects bool. Good catch.
http://msdn.microsoft.com/en-us/libr...h1(VS.71).aspx