title: How to sort array items by longitude latitude distance in javascripts?
body: <p>I am having following JSON array of 6 locations. Is there any way sort these based on longitude and latitude where nearby locations come next in the array? </p>
  
  <pre><code>[
  {"id" : 279, "longitude":79.853239,"latitude":6.912283},
  {"id" : 284, "longitude":79.865699,"latitude":6.885697},
  {"id" : 13,  "longitude":79.851187,"latitude":6.912220},
  {"id" : 282, "longitude":79.858904,"latitude":6.871041},
  {"id" : 281, "longitude":79.853346,"latitude":6.899757},
  {"id" : 16,  "longitude":79.854786,"latitude":6.894039}
  ]
  </code></pre>
  
  <p>Sorting can be started from first item and result should be something like this</p>
  
  <pre><code>[
  {"id" : 279, "longitute":79.853239,"latitude":6.912283},
  {"id" : 13,  "longitute":79.851187,"latitude":6.912220},
  {"id" : 281, "longitute":79.853346,"latitude":6.899757},
  {"id" : 16,  "longitute":79.854786,"latitude":6.894039},
  {"id" : 284, "longitute":79.865699,"latitude":6.885697},
  {"id" : 282, "longitute":79.858904,"latitude":6.871041}
  ]
  </code></pre>