If you have CLLocation instances, you can get their relative distance using:
- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location
Now you write:
My algorithm sucks - any ideas?
Well, what is your algorithm? Why does it suck? Any code you have?
From the high level perspective, I would do it like this:
- compute the distace for each airport coordinate from the curent distance in O(n), where n is number of coordinates
- sort the items using some stable algorithm like QuickSort (...NSArray's sort should work OK...) which takes you O(n*log n), or make it work so that you can use radix sort that work in O(n)
Is there a reason why this wouldn't work? :)