• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hint on OOP-3 Please

 
Daniel Loranz
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Daniel Loranz
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. The thread looks very helpful.
 
Daniel Loranz
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic