title: Sort array based on geolocation
body: <p>I want to sort array/object of cities based on my location from nearest (to my location) to furthest</p>
  
  <p>I have list of locations that i get from database
  How would i solve this using javascript and HTML5 geolocation?</p>
  
  <p>I have something like this:
  example :</p>
  
  <pre><code>var locations= [{"name":"location1" "latitude" :"31.413165123" 
  "longitude":"40.34215241"},{"name":"location2" "latitude" :"31.413775453" 
  "longitude":"40.34675341"}]
  </code></pre>
  
  <p>and I want to sort those location by nearest to my location</p>