aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Alphabetizing an ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Alphabetizing an ArrayList" Watch "Alphabetizing an ArrayList" New topic
Author

Alphabetizing an ArrayList

J. Floyd
Greenhorn

Joined: Apr 27, 2010
Posts: 5
Hello,

I am trying to alphabetize the contents of an arrayList by last name. I am completely stuck. Each element in the arrayList contains a string for first name, last name, address, city, state, zip, phone, fax. There are also two optional strings for cell and email.

Here is my code:


The program is not working. I commented out the Collections line and kept getting this as my output: [[Ljava.lang.Object;@13d93f4].

Any help would be greatly appreciated.

Thank you.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2182
    
    7
You need to create a custom Object to store the individual properties. Then you can use a Comparator to sort on a specific property. Something like:

Sorting People by Name

Or you may find the Bean Comparator helpfull since you won't have to write a custom Comparator.
J. Floyd
Greenhorn

Joined: Apr 27, 2010
Posts: 5
Thank you. I ended up getting it to work in the SQL statement that retrieves the database. I appreciate your help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Alphabetizing an ArrayList