Continuing from where I've left off, I want to limit the number of postcodes (only select up to x, but for now, say 4).
point_a = Geokit::Geocoders::GoogleGeocoder.geocode "se18 7hp"
alpha = ["cr0 3rl", "W2 1AA", "abc 234", "aol 765", "wv1 111"]
miles = alpha.map do |m| point_a.distance_to(m) end
#=> an array of numbers in miles
The answer to return the nearest postcode was with: alpha[miles.index(miles.min)]
I am trying to return the nearest 4:
alpha[miles.index(miles[0..3].min)] # surely not possible
The question is, how to return an array of the nearest 4 postcodes?