title: Sort Points Using C++
body: <p>I have an array of <em>std::vector&lt;cv::Point&gt;</em> that looks like-</p>
  <pre><code>[49, 500]
  [49, 129]
  [441, 501]
  [49, 374]
  [440, 374]
  [440, 259]
  [440, 128]
  [49, 260]
  </code></pre>
  <p>Let consider array elements as <em>[x, y]</em>. Now I need to get 4 elements from the array having-</p>
  <ol>
  <li>lowest x with highest y</li>
  <li>lowest x with lowest y</li>
  <li>highest x with lowest y</li>
  <li>highest x with highest y</li>
  </ol>
  <p>currently, I am using functions to sort based on conditions and then fetch a point.</p>
  <pre><code>bool SortForMinXMaxY(const Point &amp; a, const Point &amp;b) 
  {
      return (a.x &lt; b.x || a.y &gt; b.y) ;
  }
  </code></pre>
  <p>What should be the standard approach with C++ and OpenCV to achieve the goal?</p>