Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Collection Sort
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.*;

public class GFG {
public static void main(String[] args)
{
// Create a list of strings
ArrayList<String> al = new ArrayList<String>();
al.add("AB 11 ");
al.add("Car");
al.add("Bike");
al.add("Football");
al.add("Travel");

/* Collections.sort method is sorting the
elements of ArrayList in ascending order. */
Collections.sort(al, Collections.reverseOrder());

// Let us print the sorted list
System.out.println("List after the use of"
+ " Collection.sort() :\n" + al);
}
}