aforward/geokit-premier-gem — pull request #2 by pcorliss (2012-04-13 16:37:15+00:00)
Title: Fixing the sorting in the json2GeoLoc method

Fixing the sorting in the json2GeoLoc method such that results are sorted by their accuracy, but maintain the order of results that have the same accuracy. Basically, sorting the groups of results by accuracy, as opposed to the results themselves.

Paired with Dave Giunta

You can see an example of incorrect behavior by running the following. This patches maintains the order returned by google and returns 'Boston, MA'

>> geo_resp = Geokit::Geocoders::GoogleGeocoder3.do_geocode('Boston')
>> geo_resp.all.map(&:full_address)
=> ["Boston, NY 14025, USA", "Boston, KY 40107, USA", "Boston, VA 22713, USA", "Boston, GA 31626, USA", "Boston, IN, USA", "Boston, MA, USA"]
>> geo_resp.full_address
=> "Boston, NY 14025, USA"