What is the main goal of a sorting algorithm?
ArrayList into a specified order, either ascending from small to large or descending from large to small.
Explanation
The order has to be chosen before any tracing begins, because ascending and descending produce different intermediate states from the same starting data. Sorting changes positions but keeps the same values.
- A is not correct: Stopping at the first value that matches a target leaves the rest of the collection in whatever order it started in, so nothing is arranged.
- B is not correct: Reversing positions without comparing values ignores the ordering entirely, and no algorithm here can place a value without comparisons.
- D is not correct: Sorting keeps the same values and only moves them, so no element is discarded and duplicates stay in the collection.