From c4daea11c3e980b62acd11da59205588e73720b3 Mon Sep 17 00:00:00 2001 From: AaryaB11 <73346599+AaryaB11@users.noreply.github.com> Date: Fri, 23 Oct 2020 19:11:52 +0530 Subject: [PATCH] Collection Sort --- Collection Sort | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Collection Sort diff --git a/Collection Sort b/Collection Sort new file mode 100644 index 0000000..a022172 --- /dev/null +++ b/Collection Sort @@ -0,0 +1,22 @@ +import java.util.*; + +public class GFG { + public static void main(String[] args) + { + // Create a list of strings + ArrayList al = new ArrayList(); + 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); + } +}