+ 3
How to sort an array from highest to lowest?
Arrays.sort();
6 Respostas
+ 4
Here is implementation
https://code.sololearn.com/cPfdfkcaRNQu/?ref=app
https://code.sololearn.com/cvRS4J69Lfzo/?ref=app
+ 3
Brother don't use methods in learning period, go for algorithms.
Use Bubble sort, selection sort etc. It will strength your concept.
+ 2
If your array contains objects, you can reverse sort easily:
Arrays.sort(data, Collections.reverseOrder());
If your array contains primitive data types, it is more complicated, possibly by using streams, or converting to reference type (eg. int to Integer).
https://stackoverflow.com/questions/1694751/java-array-sort-descending
0
John Emmanuel Piga There is a lot of sorting algorithms. Like Nitin Tiwari said firstly try bubble sort then try something more powerful.
0
We can use bubble sort , quick sort mainly we can use merge sort which is the best
0
import java.util.Arrays;
import java.util.Comparator;
...
Integer[] aInt = {6,2,3,4,1,5,7,8,9,10};
Arrays.sort(aInt, Comparator.reverseOrder() );
System.out.println( Arrays.toString( aInt ) );