You can do Map.values(), put the resulting Collection in a List, and then sort the List.
If you want access to the keys, you can first create a reverse mapping, and then sort the keys of the reverse map, or better yet use a Map implementation that has sorted keys for the reverse map.
Or, you can do Map.entrySet(), put the result into a List, and then sort the List, using your own Comparator that sorts by values first and then by keys.
You can sort with Collections.sort().
To sort Strings without regard to case, use java.lang.String.CASE_INSENSITIVE_ORDER.
Most of the capitalized words above are classes or interfaces in the java.util package.
Thanks, this works fine for me.
> You can do Map.values(), put the resulting Collection
> in a List, and then sort the List.
>
> If you want access to the keys, you can first create
> a reverse mapping, and then sort the keys of the
> reverse map, or better yet use a Map implementation
> that has sorted keys for the reverse map.
>
> Or, you can do Map.entrySet(), put the result into a
> List, and then sort the List, using your own
> Comparator that sorts by values first and then by
> keys.
>
> You can sort with Collections.sort().
>
> To sort Strings without regard to case, use
> java.lang.String.CASE_INSENSITIVE_ORDER.
>
> Most of the capitalized words above are classes or
> interfaces in the java.util package.