litiales
litiales

Reputation: 171

HashMap and sorting

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

Answers (1)

Sebastien
Sebastien

Reputation: 6562

You should put the map.keySet in a list sort it and iterate on this list of sorted keys.

Upvotes: 4

Related Questions