aspose file tools*
The moose likes Cattle Drive and the fly likes OOP3-SortNames Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "OOP3-SortNames" Watch "OOP3-SortNames" New topic
Author

OOP3-SortNames

Colm Dickson
Ranch Hand

Joined: Apr 04, 2009
Posts: 89
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

Joined: Sep 13, 2007
Posts: 2584
    
    9

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

K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Colm Dickson
Ranch Hand

Joined: Apr 04, 2009
Posts: 89
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

Joined: Nov 12, 2008
Posts: 318
    
    6

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.
 
 
subject: OOP3-SortNames