views:

590

answers:

2

Is there any EASY way to sort an array in descending order like how they have a sort in ascending order in the Arrays class http://www.j2ee.me/javase/6/docs/api/java/util/Arrays.html

?

Or do I have to stop being lazy and do this myself :[

+8  A: 

You could use this

sort(T[] a, Comparator<? super T> c) 

Arrays.sort(a, Collections.reverseOrder());
alinrus
+3  A: 

You can use This:

    Arrays.sort(data,Collections.reverseOrder());

Collections.reverseOrder() returns a Comparator using the inverse natural order or you can get a inverted version of your own comparator using Collections.reverseOrder(myComparator).

William
The OP wants to sort an array. `Collections.sort()` takes a `List` as input parameter, not an array.
Pascal Thivent
ops,i wrote Collections instead of Arrays.Its corrected now.
William