File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to get sub lists of a list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to get sub lists of a list" Watch "How to get sub lists of a list" New topic
Author

How to get sub lists of a list

pjoisha
Ranch Hand

Joined: Mar 06, 2001
Posts: 123
Hi all,
I'm using Arrays.sort(Object[], Comparator) to help sort some of my objects. However, I now have a need to create sublists off of a sorted list
For example I have a list of following objects
Person[] person = new Person[3];
// The Person constructor takes
// LastName, FirstName
person[0] = new Person(Goodyear, Nancy);
person[1] = new Person(Clark,Stanley);
person[2] = new Person(Goodyear, Elvis);
I sort them
Array.sort(person, Person.LastNameComparator);
The list ends up being
Clark, Stanley
Goodyear, Nancy
Goodyear, Elvis
However, what I want the sort interface to return is a an array of sub lists (each sub list has only duplicates in them) as follows
SubList1: Clark, Stanley
SubList1: Goodyear, Nancy
Goodyear, Elvis
Are there any Java APIs or some other techniques available to do this?
Thanks in advance
PJ
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1821

I have always used something akin to the following:


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
pjoisha
Ranch Hand

Joined: Mar 06, 2001
Posts: 123
Thanks Joel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get sub lists of a list