Yes.
You need to provide a Comparator that provides the opposite results fro the "normal" order. I think Collections has one called ReverseOrder.
[url=http://www.onjava.com/lpt/a/3286]Making Java Objects Comparable[/url]
http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html
http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html
import java.util.*;
public class SortExample {
public static void main(String[] args) {
String[] data = {"Hey", "ho", "here", "We", "go"};
Arrays.sort(data, Collections.reverseOrder());
System.out.println(Arrays.toString(data));
Arrays.sort(data, Collections.reverseOrder(String.CASE_INSENSITIVE_ORDER));
System.out.println(Arrays.toString(data));
}
}
this is giving me compilation errors as below:
C:\TEMP\SortExample.java:7: toString() in java.lang.Object cannot be applied to (java.lang.String[])
System.out.println(Arrays.toString(data));
^
C:\TEMP\SortExample.java:8: reverseOrder() in java.util.Collections cannot be applied to (java.util.Comparator)
Arrays.sort(data, Collections.reverseOrder(String.CASE_INSENSITIVE_ORDER));
^
C:\TEMP\SortExample.java:9: toString() in java.lang.Object cannot be applied to (java.lang.String[])
System.out.println(Arrays.toString(data));
^
3 errors
any help.