Question: Instructions Write a method, public static void sortAndPrint(string arr) which implements an insertion sort on the array list Unlike in the exercise from the previous


Instructions Write a method, public static void sortAndPrint(string arr) which implements an insertion sort on the array list Unlike in the exercise from the previous lesson, this method should print the values in the array (on one line with a single space between values) multiple times: once after each insertion in the algorithm has been completed (even if a value is inserted in its original place). Make sure to use the String compare Too method when sorting to decide the correct order of the Strings For example, if sortAndPrint method is called with the array arr initialised as "sout", "oke", "torch, ferind", "lease") then the following should be printed: joke soul torch mind lease joke soul torch wind Lease Joke wind soul torch lease joke lease mind soul torch Write your sortAndPrint method in the U7_L6 Activity One class. Use the runner class to test your method but do not add a main method to your U7 L6 Activity One.java file or your code will not be scored correctly. Files STATUS NOT SUBMITTED SAVE SUBMIT U7_L6_Activity_One.java 1 public class U7_L6_Activity_One 2-{ 4 //Write the sortAndPrint method described in the assignment 5 6} 7 runner_U7_L6_Activity Files Shives NOT SUBMITTED SAVE SUBMIT U7_L6_Activity One.java runner_U7_L6_Activity_... 1 - import java.util.Scanner; 2 - public class runner_U7_L6_Activity_one { 3- public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter array length: "); int len - scan.nextIntO; scan.nextLine(); String[] wordList - new String[len]; System.out.println("Enter values:"); for(int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
