Write a class for sorting strings into lexicographic (alphabetical) order that f
ID: 3618184 • Letter: W
Question
Write a class for sorting strings into lexicographic (alphabetical) order that follows the outline of the class SelectionSort in display 6.11 of Chapter 6. Your definition, however, will use an ArrayList of the Class ArrayList , rather than an array of elements of type double. For words, lexicographic order reduces to alphabetic order if all the words are in either all lowercase or all uppercase letters. You can compare 2 strings to see which is lexicographically first by using the String method compareTo. For string S1 and S2: s1.compareTo(s2) returns a negative number if s1 is lexicographically before s2, returns 0 if s1 = s2 and returns a positive number if s1 is lexicographically after s2. Call your class StringSelectionsort.Explanation / Answer
publicclass StringSelectionSort { publicvoid sort(ArrayList data) { for(int i= 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.