-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectionSort.java
More file actions
22 lines (15 loc) · 601 Bytes
/
CollectionSort.java
File metadata and controls
22 lines (15 loc) · 601 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package collection;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class CollectionSort {
public static void main(String[] args) {
String[] suits = { "Hearts", "Diamonds", "Clubs", "Spades" };
// Create and display a list containing the suits array elements
List<String> list = Arrays.asList(suits); // create List
System.out.printf("Unsorted array elements: %s\n", list);
Collections.sort(list, Collections.reverseOrder()); // sort ArrayList
// Output list
System.out.printf("Sorted array elements: %s\n", list);
}
}