File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Cattle Drive and the fly likes Hint on OOP-3 Please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Hint on OOP-3 Please" Watch "Hint on OOP-3 Please" New topic
Author

Hint on OOP-3 Please

Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41
Sorting by first name was pretty straightforward.

I'm stuck on sorting by last name while staying within the parameters of the assignment. I could build a new list with the elements being lastName, firstName, but I think this violates the assignment requirements.

Does Comparator help me in this assignment?

Thanks.
Nathan Leniz
Ranch Hand

Joined: Nov 26, 2006
Posts: 132
Hi Daniel.

This assignment gave me fits. I'd highly recommend searching for all topics titled sortnames in the cattledrive forum. Read through a few, the information found there is invaluable.

This thread was pretty good as far as dropping a key hint in the right direction, and there are several others which now (looking back on the problem and knowing what needs to be done) almost give you the answer. Also I did a google search for "how to sort an arraylist alphabetically" after looking through the search results on JavaRanch and studying Collections on the Java tutorial through Sun, and the answer almost jumped out and bit me.

Just remember that you'll need to implement an interface, where one of the implemented methods does some comparing. You need to tell it exactly where to compare.


The very existence of flamethrowers proves that at some time, some where, some place, someone once said to themselves "I'd really like to set those people on fire over there, but I just can't get close enough".
Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41
Thanks. The thread looks very helpful.
Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41


Whew! Got SortNames to work - and I feel GREAT! Wow, what an awesome example of the usefulness of an object approach. It took me quite awhile to work out how to properly fit my own classes into the larger java picture, but when I finally got the syntax correct, the amount of coding on my part was quite minimal. Very cool!

Very nice!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hint on OOP-3 Please