Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Sorting values in a HashMap into alphabetical order

807589Sep 22 2008 — edited Sep 22 2008
I am trying to sort a set of String values from a HashMap into alphabetical order. So far i have a method which will perform the sort between two strings, but I cannot figure out how I can apply this to another data structure, e.g. a LinkedList, whereby I can search through all of the entries in the map and then place them in the correct order.
	private Integer compareStrings(String string1, String string2){

    	return string1.compareTo(string2);    	
}
I realise that there probably is a way of doing this that is built-in to the API, but have had no luck finding it. Can anyone shed some light on this?
If I have not explained my problem fully, please let me know.

Regards

Will
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 20 2008
Added on Sep 22 2008
11 comments
1,877 views