I've recently learned how to sort arrays in ascending order with this code in Java;
int swapIndex,temp;
for(int index=0; index<=array.length-2; index++) {
swapIndex = index;
for(int i=index+1; i<=array.length-1; i++)
if(array[i]<array[swapIndex]) swapIndex = i;
temp = array[index]; array[index] = array[swapIndex];
array[swapIndex] = temp;
}
}
Can somebody please tell me how to I can use this code but sort in descending order? Best regards