11.09. Sorting and Reversal of Elements

Sorting and reversal of elements

  • Eclipse: Oxygen
  • Java: 1.8

The sorting and reversal of elements from the Collections are shown in the article by the built-in functions in the collection frameworks.

The following example demonstrates the alphabetical sorting of the List of country names. sort() method will sort the elements (country names) of the  LinkedList using natural ordering (alphabetically in ascending order).

Output

Following program is the declaration for Collections.reverse() method. It reverses the current order of the list.

Output

Contributed by: Poonam Tomar

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments