java example of sorting arraylist of valueobjects based on the property
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Lokesh_Nagappa
Posted On:   Tuesday, November 18, 2003 04:21 AM

java example of sorting arraylist of valueobjects based on the property

Re: java example of sorting arraylist of valueobjects based on the property

Posted By:   AlessandroA_Garbagnati  
Posted On:   Tuesday, November 18, 2003 08:35 AM

Hi,

Well, you can create an object that implements the java.util.Comparator interface.

To do that just simply implement the compare(Object obj1, Object obj2) and equals(Object obj) methods.

Based on your needs you can create one or more simple comparators or even more comparators that work based on parameter that are provided on creation.


Then, once you have your comparator(s), sorting your list is as simple as calling the Collections.sort(List list, Comparator c) method.

About | Sitemap | Contact