Reputation: 5
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
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