Modify the insertionSort algorithm so that it sorts indescending order rather than ascending order.
public static void insertionSort(Comparable[] list)
{
for (int index = 1; index <list.length; index++)
{
Comparable key =list[index];
int position =index;
// Shift largervalues to the right
while (position> 0 && key.compareTo(list[position – 1]) < 0)
{
list[position] = list[position – 1];
position–;
}
list[position] =key;
}
}
Answer
public static void insertionSort(Comparable[] list) { for (int index = 1; index < list.length;
OR
OR