Home Sort a Map<Key, Value> by values (Java)
Reply: 0

Sort a Map<Key, Value> by values (Java)

user417 Published in January 18, 2018, 12:18 am

I am relatively new to Java, and often find that I need to sort a Map<Key, Value> on the values. Since the values are not unique, I find myself converting the keySet into an array, and sorting that array through array sort with a custom comparator that sorts on the value associated with the key. Is there an easier way?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.710594 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO