481,366 views
20 votes
20 votes
The Collections class of Java Collection Framework has several methods (e.g. sort(), min(), max()) that require natural ordering of the classes to be handled. Explain the two possible conditions that must be satisfied on the classes to be able to use the sort()method to arrange the list of objects these classes.

User Sushil Sharma
by
2.7k points

1 Answer

5 votes
5 votes

Answer:

Step-by-step explanation:

Java Collections sort() Method :

By default, this method sorts the unsorted list into ascending order , according to the natural ordering of the list items. We can use Collections.reverseOrder() method for reverse sorting.

Condition are basically for any sorting algo. First one the Output is in non-decreasing order (Each elements is no smaller than the previous element according to the desired total order). Second is the output is a permutation (a reordering, yet retaining all of the original elements) of the input.

The Collections class of Java Collection Framework has several methods (e.g. sort-example-1
The Collections class of Java Collection Framework has several methods (e.g. sort-example-2
The Collections class of Java Collection Framework has several methods (e.g. sort-example-3
User Cheshie
by
3.3k points