title: How to use std::sort with a vector of structures and compare function?
body: <p>Thanks for a <a href="https://stackoverflow.com/questions/327893/how-to-write-a-compare-function-for-qsort-from-stdlib">solution in C</a>,
  now I would like to achieve this in C++ using std::sort and vector:</p>
  
  <pre><code>typedef struct
  {
    double x;
    double y;
    double alfa;
  } pkt;
  </code></pre>
  
  <p><code>vector&lt; pkt &gt; wektor;</code> filled up using push_back(); compare function:</p>
  
  <pre><code>int porownaj(const void *p_a, const void *p_b)
  {
    pkt *pkt_a = (pkt *) p_a;
    pkt *pkt_b = (pkt *) p_b;
  
    if (pkt_a-&gt;alfa &gt; pkt_b-&gt;alfa) return 1;
    if (pkt_a-&gt;alfa &lt; pkt_b-&gt;alfa) return -1;
  
    if (pkt_a-&gt;x &gt; pkt_b-&gt;x) return 1;
    if (pkt_a-&gt;x &lt; pkt_b-&gt;x) return -1;
  
    return 0;
  }
  
  sort(wektor.begin(), wektor.end(), porownaj); // this makes loads of errors on compile time
  </code></pre>
  
  <p>What is to correct? How to use properly std::sort in that case?</p>