Troubles with list<ofPoint> sort compare method

Hi @ all,

i have a littl problem, that i cannot solve, i don’t know where my mistake is.

What i have:

  
  
  
list <ofPoint>		catMullLine;  
bool comparePoints(ofPoint first, ofPoint second);  
  
  

**
Than filling my catMullLine:**

  
  
catMullLine.push_back(ofPoint(linePosition.x, linePosition.y - 20));  

**
Afterwards, i try to sort:**

  
catMullLine.sort(comparePoints);  

Error i’m getting (translated from german)
"“Game::comparePoints” Function is missing parameters, use &Game::comparePoints to create a pointer onto a member

It would be cool, if anyone could give me any advice :frowning:

thanks

Allright sparky,

with ofPoints its a bit tricky. With the help of a friend, the problem is solved.

  
testApp.h  

  
struct compare : public std::binary_function<ofPoint, ofPoint, bool>  
{  
	bool operator()(ofPoint p1, ofPoint p2) const{  
		if(p1.x<p2.x)  
			return true;  
		else  
			return false;  
	};  
};  

usage:

  
pts.sort(compare());  

TestApp is included.

sortOfPoints.rar

hi circassia,

easier option here:

  1. the function must be static
  2. the parameters you pass in to the comparePoints function must be const references.

try this as your method signature:

  
static bool comparePoints(const ofPoint& first, const ofPoint& second)  

hth,
d