I have 2 arrays that are related. The first array is an array of distances from a certain spot. The second array is an array of city names. They are related in that the order of the distances array is the same initial order as the city array.
I want to sort the distance array, which I know is easy enough using the sort() method. The part I can't do is sorting the city array according to the distance array.
For example:
arraydistance = [43, 934, 831]
arraycity = [la, sandiego, orangecounty]
After the sort it should look like:
arraydistance = [43, 831, 934]
arraycity = [la, orangecounty, sandiego]
It might be cleaner or easier to put them into the same array, but I still wouldn't know how to sort. Any advice would be much appreciated!
Thanks