title: how to sort elements by one measure
body: <p>In C++ I don't quite understand how to sort elements, by defining a custom function. </p>
  
  <p>Cppreference.com says that for the comparison function:</p>
  
  <blockquote>
    <p>comp - comparison function which returns ​​true​ if the first argument
    is less than the second.</p>
    
    <p>​bool cmp(const Type1 &amp;a, const Type2 &amp;b);​</p>
  </blockquote>
  
  <p>Naturally I would think that for sorting elements I would need to define a measure, and the sort function would sort them depending on the measure.</p>
  
  <p>In my actual example I would like to sort image files depending on how far they are from a camera. I have a vector of boost::filesystem::path linking to directories of image sequences</p>
  
  <pre><code>vector&lt;boost::filesystem::path&gt; path_vec
  </code></pre>
  
  <p>and I would naturally think that I need to write a function like</p>
  
  <pre><code>double z_distance( boost::filesystem::path filename, integer time )
  </code></pre>
  
  <p>what would return a double for all the elements and sort them in ascending or descending order for every frame (thus the changing time in the argument). </p>
  
  <p><strong>Can you tell me how should I turn this function which returns a single value, into a bool function needed for the sort function?</strong> </p>
  
  <p><strong>And how could I pass arguments</strong>, if I can only pass a function name, not a full call to a function?</p>