We use a combination of geospatial features from our database (MongoDB) and linear algebra to compute the distances on a coordinate grid. Admittedly this isn't a flawless approach, and cases like yours reveal some of the weaknesses. Certainly open to suggestions on a better way :)
With regards to ordering of results, it is mostly by distance, with some outliers. Definitely an area we are working on improving.
Thanks for the kind words.