Sorting vector values by Distance in vector
<p>I have two locations, My player location (2D) and I'm looping over a vector of entitys each with a location (2D), I would like my function to return the closest distance to my location, But I don't know how to do it because I got stuck, in c# I could just use linq, But i'm learning c++ My function looks like this:</p>

<pre><code>const Entity GetNearestEntity()
{
    for (Entity i : fb.Entities)
    {
        double xDiff = (double)abs(fb.PlayerLocation.X - i.X);
        double yDiff = (double)abs(fb.PlayerLocation.Y - i.Y);

        //Stuck here.. 
        //How can i get the closest object out of my vector&lt;Entity&gt; collection?
    }
}
</code></pre>

<p>help appreciated! </p>
