I have
java application, to sort names of address book in Ascending order. I used following code for that:
Collections.sort(set,SortEngine.NAME);
In SortEngine is class:
public static final Comparator NAME = new Comparator()
{
public int compare(Object o1, Object o2)
{
try
{
SortEngine name1 = (SortEngine)o1;
SortEngine name2 = (SortEngine)o2;
return name1.name.compareTo(name2.name);
}
catch(ClassCastException e)
{
// do something here
}
return 0;
}
// do something for equals too
};
I only did for Ascending order. How to do in Descening order? so, user can do sort by Ascending and Descending order.
Thanks,
Angela