title: Sort 2D points counter clockwise
body: <p>My question is related to this one: <a href="https://stackoverflow.com/questions/39187184/c-sorting-2d-points-clockwise/39187213#39187213">c++ Sorting 2D Points clockwise</a>, but somehow that solution doesn't work for me. I am trying to sort 4 2d points counter clockwise.</p>
  
  <p>This is my code: </p>
  
  <pre><code>typedef struct p {
  float x,y;
  } Point;
  
  double getClockwiseAngle(Point p) {
  double angle = 0.0;
  
  angle = atan2(p.x, -p.y);
  return angle;
  }
  
  bool comparePoints(Point p1, Point p2) {
       return getClockwiseAngle(p1) &lt; getClockwiseAngle(p2);
  }
  
  int main() {
      ...
      sort(givenPoints.begin(), givenPoints.end(), comparePoints);
      ...
  }
  </code></pre>
  
  <p>Example: 
  Input (-4, 2), (1, 4), (0,1), (-1, 4)</p>
  
  <p>Output (-4, 2), (-1, 4), (1, 4), (0,1) </p>