Question
The Insertion Sort method below is used to sort arrays of ints in ascending order. Modify the function to sort Strings in descending order. Remember,
The Insertion Sort method below is used to sort arrays of ints in ascending order. Modify the function to sort Strings in descending order. Remember, strings can be compared using the compareTo method.
str1.compareTo(str2) will return a negative value when str1 would come before str2 alphabetically, a positive value when str1 comes after str2 alphabetically, and zero when the strings are equal.
public static void insertionSort(int[] data) { for (int i=1; i
BoldItalicUnderline
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started