title: Ordering a list of points nearest to a given point
body: <p>I am trying to order a list of points by distance from a given point. </p>
  
  <p>The application is to find the nearest landmarks (gps coordinates) to your current gps coordinate.  </p>
  
  <p>so if you take the following code : </p>
  
  <pre><code>public static void main(String[] args) throws SQLException {
          ArrayList&lt;Point2D.Double&gt; points = new ArrayList&lt;Point2D.Double&gt;();
  
          Point2D.Double point1 = new Point2D.Double(1,1);
          Point2D.Double point2 = new Point2D.Double(2,2);
          Point2D.Double point3 = new Point2D.Double(3,3);
  
          points.add(point1);
          points.add(point2);
          points.add(point3);
  
          Point2D.Double myPoint = new Point2D.Double(4,4);
  
      }
  </code></pre>
  
  <p>If i use a Comparator to sort the points array I will get a nice ordered list of points but how do I find which one is closer to myPoint? and what are the distances.  </p>
  
  <p>That should certainly answer my question, but for bonus points.. how can I limit the result of points back if give a maximum distance. eg : return an ordered list of coordinates that are no further than 100 miles.</p>