I was able to sort the numbers in the matrix from smallest to largest, but I could not sort them from largest to smallest. please help...
int[] list = new int[4];
System.out.println("Enter the numbers of array: ");
for (int i = 0; i < list.length; i++)
list[i] = kbd.nextInt();
for (int index = 0; index < list.length; index++) {
int minIndex = index;
for (int i = index + 1; i < list.length; i++) {
if (list[i] < list[minIndex])
minIndex = i;
}
int temp = list[index];
list[index] = list[minIndex];
list[minIndex] = temp;
}
System.out.println("Numbers after sorting: ");
for (int j : list) System.out.print(j + " ");