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 :[
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 :[
You could use this
sort(T[] a, Comparator<? super T> c)
Arrays.sort(a, Collections.reverseOrder());
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).