This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OOP3-SortNames

 
Colm Dickson
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.

My query is not on how this is achieved but on the ordering of the names.
Using the Collections class alone ordering can be achieved as I would expect (by first and then last name) though I know a more involved approach is required.
So given the names list, can someone leave an brief example of what the resultant list should be like? I'm now confused in thinking that the ordering is different to how I perceive it to be?
Are the surnames supposed to be incorporated with the first names so that there is one list ordered be it a first name or surname.

A sample of the desired output (not the code!) will send me on my way again!

Thanks

C
 
K. Tsang
Bartender
Posts: 3348
12
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,

When I did it my final output is:

original data
Adam Baum
Justin Case
Bill Joy
James Gosling
Walter Cronkite
Joe Montana
Abraham Lincoln
Connie Chung

sorted by first names
Abraham Lincoln
Adam Baum
Bill Joy
Connie Chung
James Gosling
Joe Montana
Justin Case
Walter Cronkite

sorted by last names
Adam Baum
Justin Case
Connie Chung
Walter Cronkite
James Gosling
Bill Joy
Abraham Lincoln
Joe Montana
 
Colm Dickson
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi and thanks for replying.

I see what you mean now. My understanding of the question made me think it was 'order by first name, last name' much in the same way a select from database would return if ordered that way(which happens to be the way the natural sort from arraylist occurs) . So , what it's asking for is two results, the original list sorted two ways, first by first name and then by last name as in your example?

Thanks again.

C
 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Colm,

The original list is part of the output for the assignment. When the program is run the output has 3 sets of data just as K. Tsang posted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic