This class is being retrieved to my by hibernate in form of list. I need to implementing sorting on it. I just read that i need to Comparable interface on it and then i can do the rest.
I have one question
What if i need to sort the List of this bean on different columns i.e at one place may be i need sorting at field1 and at some place may be i need at date and on the other place i'll be looking to sort the list on id.
What could be the best possible way of doing this?
The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
Originalliy posted by Muhammad Ali: For this I'd have to implement the sort method.
Actually not. Wirianto Djunaidi is quite right. Have a look at the java.util.Comparator interface. You don't have to implement sort(), but to provide a Comparator which performs a comparison on pairs of your bean objects. For each column to sort, you can provide a different Comparator.