Link to home
Start Free TrialLog in
Avatar of bvdm23
bvdm23

asked on

Sort a Hashtable

Hello all,

I have a Hashtable with as a key a String and as a value a String.
Now I want to sort this HashTable by the value while still be able to retreive the
key.

Can anybody help me with this?

Thanks in advance,

bvdm23
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>  as they have no inherrant order

By this I mean that you can think of Hashtables, Sets, etc as being like a bag of sweets...  To sort them (in order of colour or size), you will have to put them in a struture that can hold order (like a queue, or list) :-)

Hope that makes more sense :-)

Tim
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why I take so much time in typing?????????
Hehehehe :-)
Try a TreeMap with a custom Comparator that compares the mapped values.