Question: Write a method, public static void sortAndPrint(String [] list), which implements a selection sort on the array list and prints the sorted values in order.
Write a method, public static void sortAndPrint(String [] list), which implements a selection sort on the array list and prints the sorted values in order. Make sure to use the String.compareTo() method when sorting to decide the correct order of the Strings. For example, consider the following code: String [] list = { "against" , "forms" , "belief" , "government" , "democratic" , "movement" , "understanding"}; sortAndPrint(list); The should print the following: against belief democratic forms government movement understanding For this activity, include your method in a class called Lesson_15_Activity. Copy the entire class into the coderunner box and press run.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
