Question: Task 5 (20 pts.) File SortBylength.java given below contains an incomplete program. The goal of the program is to read a text file into an

 Task 5 (20 pts.) File SortBylength.java given below contains an incomplete

program. The goal of the program is to read a text file

into an array list of strings, and then sort th strings appear

Task 5 (20 pts.) File SortBylength.java given below contains an incomplete program. The goal of the program is to read a text file into an array list of strings, and then sort th strings appear in ascending order of their length. Complete that program, by defining a sortByLength function, that satisfies the following specs: at list, so that the Function sortByLength takes one argument, called input_list, that is an array list of strings. The function should return an array list called result with length equal to the length of A. The result should contain the same elements as A, but in ascending order of their length. IMPORTANT: You are NOT allowed to modify in any way the main function. Y auxiliary functions. ou are free to define and use Hint: my solution also includes (and uses) the insertBeforeLonger function from the previous task. My solution takes five lines of code, in addition to the insertBeforeLonger function. This is an example run of the program, using input file fmlin1.txt Please enter the name of the input file: fmlinl.txt Input: [whale, cat, elephant, donkey, goat] output: [cat, goat, whale, donkey, elephant ] This is an example run of the program, using input file fmlin2.txt Please enter the name of the input file: fmlin2.txt Input: (Massachusetts, Texas, oregon, Utah, california, New York, Florida] output: [Utah, Texas, Oregon, Florida, New York, california, Massachusetts ] SortByLength.java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!