Reverse Order Sorting

Sorting the List in reverse Order
package com.learn;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Test {
    public static void main(String[] args) {
      
        List<String> normalOrder = new ArrayList<String>();
        normalOrder.add("A");
        normalOrder.add("B");
        normalOrder.add("C");
        System.out.println("before Sorting : "+normalOrder);
        Collections.sort(normalOrder,Collections.reverseOrder());
        System.out.println("After Sorting :"+normalOrder);
      
    }


O/P for the above Program is :
before Sorting : [A, B, C]
After Sorting :[C, B, A]









0 Response to "Reverse Order Sorting"

Post a Comment