Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I wrote this code, but I want to know how to alphabetize the monthsusing the com

ID: 3618226 • Letter: I

Question

I wrote this code, but I want to know how to alphabetize the monthsusing the compareTo() method (I know this way is easier but I'dlike to know how to do it the tedious way).
import java.util.*;
/**
* Write a description of class LongestMonthFinder here.
*
* @author (Alex Ramos)
* @version (4/19/10)
*/
public class Alphabetized{
    public static void main(String[] args){
       
        String[] months ={"January", "February", "March"
                            ,"April", "May", "June", "July"
                            ,"August", "September","October"
                            ,"November", "December"};
                            
        Arrays.sort(months);
       System.out.println(Arrays.toString(months));
     }
}
    


Explanation / Answer

There are several sorting algorithms. Below is the selection sort. public staticvoid alphabetize(String[]months) {     for(int i= 0; i