Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 that list, so that the strings appear in ascending order of their length. Complete that program, by defining a sortByLength function, that satisfies the following specs: 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. You are free to define and use auxiliary functions. 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started