Question: Java program that needs to sort ArrayList(that contains object persons :Name, Age and Weight) by implementing the Comparable interface and the compareTo function It must
Java program that needs to sort ArrayList(that contains object persons :Name, Age and Weight) by implementing the Comparable interface and the compareTo function It must sort the Persons first by forward-alphabetical name, then by increasing age, then by increasing weight in that order. You will print the using toString() method ArrayList in a format as output

Samuel 1 123 ENTER Sammie 2 234 ENTER Sammy 3 345 ENTER Sam 4 456 ENTER I 5 567 ENTER Am 6 678 ENTER stop ENTER Original list: [{Samuel, 1, 123.0}, {Sammie, 2, 234.0}, {Sammy, 3, 345.0}, {Sam, 4, 456.0}, {I, 5, 567.0}, {Am, 6, 678.0}] In In Sorted list: [{Am, 6, 678.0}, {I, 5, 567.0}, {Sam, 4, 456.0}, {Sammie, 2, 234.0}, {Sammy, 3, 345.0}, {Samuel, 1, 123.0}]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
