RossH2106
RossH2106

Reputation: 5

How to sort a Map of LatLng,String by the order of values in an ArrayList of LatLng

Let's say I have a HashMap of Latitude/Longitudes + Names associated, and a separate ArrayList of the same Latitude/Longitudes that have been sorted by the nearest to my current location. How to I sort the HashMap to be in the same order as the ArrayList. If this is too complex then is there away to sort the initial HashMap by the nearest Latitude/Longitudes?

Upvotes: 0

Views: 92

Answers (1)

Erfan
Erfan

Reputation: 118

I think it is better to use LinkedHashMap (a Map that has order).

You can create a new LinkedHashMap and insert Latitude/Longitudes to it based on the ArrayList that you have (sorted list). Remember LinkedHashMap is ordered based on the insertion.

Upvotes: 1

Related Questions