main.js
function sortStoresByDistance(location, stores) {
  var i, s;

  for (i = 0; i < stores.length; i++) {
    s = stores[i];
    s.distance = geo.getDistanceInMiles(location,
        { lat:s.latitude, lng:s.longitude });
  }

  stores.sort(function(a,b) { return a.distance - b.distance; });
  return stores;
}
function sortStoresByDistance(location, stores) {
  var i, s;

  for (i = 0; i < stores.length; i++) {
    s = stores[i];
    s.distance = geo.getDistanceInMiles(location,
        { lat:s.latitude, lng:s.longitude });
  }

  stores.sort(function(a,b) { return a.distance - b.distance; });
  return stores;
}
function sortStoresByDistance ( location , stores ) { var i , s ; for ( i = 0 ; i < stores . length ; i ++ ) { s = stores [ i ] ; s . distance = geo . getDistanceInMiles ( location , { lat : s . latitude , lng : s . longitude } ) ; } stores . sort ( function ( a , b ) { return a . distance - b . distance ; } ) ; return stores ; }
Sorts the stores array in distance order from location, and also returns it.
@param location an object with lat and lng properties
@param stores an array of store objects
Sorts the stores array in distance order from location and also returns it .