src/main/java/sorting/SortingDemo.java
public List<String> lengthReverseSortWithComparator() {
        Collections.sort(sampleStrings, new Comparator<String>() {
            @Override
            public int compare(String s1, String s2) {
                return s2.length() - s1.length();
            }
        });
        return sampleStrings;
    }
// Java 7- using Comparator with anonymous inner class
Java 7- using Comparator with anonymous inner class
Java 7 - using Comparator with anonymous inner class
public List<String> lengthReverseSortWithComparator() {
        Collections.sort(sampleStrings, new Comparator<String>() {
            @Override
            public int compare(String s1, String s2) {
                return s2.length() - s1.length();
            }
        });
        return sampleStrings;
    }
public List < String > lengthReverseSortWithComparator ( ) { Collections . sort ( sampleStrings , new Comparator < String > ( ) { @ Override public int compare ( String s1 , String s2 ) { return s2 . length ( ) - s1 . length ( ) ; } } ) ; return sampleStrings ; }
Java 7- using Comparator with anonymous inner class
Java 7 - using Comparator with anonymous inner class