Created
January 2, 2015 16:25
-
-
Save AlexAbraham1/bd57ef550ffe5885c6ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.Comparator; | |
public class AnonymousComparator { | |
public static void main(String[] args) { | |
String[] array = {"car", "apple", "house", "awesome", "breban", "compsci", "yeshiva", "university"}; | |
Arrays.sort(array, new Comparator<String>() { | |
public int compare(String s1, String s2) { | |
return s2.compareTo(s1); | |
} | |
}); | |
System.out.println(Arrays.toString(array)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment