Connecting Tech Pros Worldwide Forums | Help | Site Map

sorting java list contains multiple list objects

Newbie
 
Join Date: Jul 2008
Posts: 1
#1: Jul 30 '08
Hi friends

guide me

to sorting java list contains multiple list objects

JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Jul 30 '08

re: sorting java list contains multiple list objects


Quote:

Originally Posted by ihimitsu

Hi friends

guide me

to sorting java list contains multiple list objects

If you have a list of objects that you want to sort then the objects have to define
a (mathematically speaking) PTO (Partial Total Ordering). It implies that you
have to be able to determine if O1 < O2 or O1 == O2. The relation O1 > O2
follows from the other two relations. Java solves this by demanding the class to
implement the Comparable interface; or alternatively you have to create
an external Comparator that implements the relations.

Read the API documentation for the interfaces mentioned above and also study
the Collections.sort() method.

kind regards,

Jos
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#3: Jul 30 '08

re: sorting java list contains multiple list objects


Have a look at the Collections.sort method.
Reply