Using insertion sort for descending order?

To sort in descending order, you only need to change the comparison:

while (j > 0 && arr[j - 1] < valueToSort) {

Note the < instead of >.

Leave a Comment

tech