in reply to Lookup closest hash key

And what if two cities have the same distance???

Please don't use this hash, or at least invert it with reverse!

I agree with Grandfather, use a data structure prepared for optimizing many lookups, like a sorted array. If the logarithmic O of a simple binary search is still to expensive you can still try niftier things like weighted searches, nested lookup tables for intervals or trees.

Cheers Rolf