Reputation: 171
I am building a trie, each node has a hashmap with sons' value stored, and keys are their name.
I'm using hashmap because, mainly, I need performances instead of sorting, instead I would have used treemap, of course.
Now, I need, just in a function, to sort hash map values by key values (that are strings). Now I'm using iterator to iterate values.
Any suggest?
Thank you
Upvotes: 0
Views: 110
Reputation: 6562
You should put the map.keySet in a list sort it and iterate on this list of sorted keys.
Upvotes: 4