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 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
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