wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes alphabetizing lists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "alphabetizing lists" Watch "alphabetizing lists" New topic
Author

alphabetizing lists

Mario Bonassin
Greenhorn

Joined: Apr 08, 2004
Posts: 18
I have no idea how to do this one. I need a simple code that will take a listModel and alphabetize the items. I would like it if it could do it with the first letter and last letter, seperatly of course.
Any suggestions or advise would be great.
Mario
sever oon
Ranch Hand

Joined: Feb 08, 2004
Posts: 268
You'll want to use java.util.Comparator and java.lang.Comparable. You can write a comparator to sort a java Collection in any way you see fit. You can also use the Comparator to instantiate sorted collections so you don't have to sort things all at once, they get inserted into their sorted positions at the time of insertion. Or, many classes already implement the Comparable interface so they have a "natural ordering". Strings have this capability already...

sev
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: alphabetizing lists
 
Similar Threads
Sorting Array of Strings
how to declare the length of the word entered?
Random ()
palindrome checker, tried to debug, keeps looping why?
Hangman BufferReader ??