0

I have this code which sorts any given number to ascending order, but I'm having difficulties figuring out how to sort the numbers given into a descending order.

Code:

```
import javax.swing.*;
import java.util.Arrays;
public class sort7
{
public static void main(int[]array)
//public static void main(String[]args)
{
String str1="";
String str2="";
String str3="";
String str4="";
String str5="";
int num1=0;
int num2=0;
int num3=0;
int num4=0;
int num5=0;
str1=JOptionPane.showInputDialog("Enter first number");
num1=Integer.parseInt(str1);
str2=JOptionPane.showInputDialog("Enter second number");
num2=Integer.parseInt(str2);
str3=JOptionPane.showInputDialog("Enter third number");
num3=Integer.parseInt(str3);
str4=JOptionPane.showInputDialog("Enter fourth number");
num4=Integer.parseInt(str4);
str5=JOptionPane.showInputDialog("Enter last number");
num5=Integer.parseInt(str5);
System.out.println("Your have entered:" +num1 +", " +num2 +", " +num3 +", " +num4 +" and "
+num5 +"." );
double[] lengths = {num1, num2, num3, num4, num5};
//double[] lengthsb = {num5, num4, num3, num2, num1};
Arrays.sort(lengths);
//Arrays.sort(lengthsb);
Arrays.sort(lengths, collections.reverseOrder());
System.out.println("Ascending order:" + Arrays.toString(lengths));
//System.out.println("Descending order:"+ Arrays.toString(lengthsb));
}
}
```

I have also tried the array.collecitonsRevers, but I seem to not get it right.

Any help would be much appreciated. Thanks!