title: std:sort does not work on vectors
body: <p>I have some problems to compile this code. I cannot find out the mistakes. The error is not because of the scope or the constant function. I also tried to put the sort method in a non-constant function and the same error occurred.</p>
  
  <pre><code>struct _Invoice {
      unsigned int amm;
      string id;
  };
  .
  .
  .    
  vector&lt;_Invoice&gt; Invoices;
  .
  .
  .
  bool invComp(const _Invoice &amp;a, const _Invoice &amp;b){
      return a.amm &lt; b.amm;
  }
  unsigned int  MedianInvoice  ( void ) const{
      vector&lt;_Invoice&gt;tmpInvoices(Invoices);
      sort(tmpInvoices.begin(), tmpInvoices.end(), invComp);
      return (tmpInvoices.begin() + ceil((double)tmpInvoices.size() / 2))-&gt;amm;
  }
  </code></pre>
  
  <p>Thanks in advance!</p>