简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM