Last active
March 8, 2016 12:45
-
-
Save sadedv/280f3f43e0948449c2d4 to your computer and use it in GitHub Desktop.
Обратная сортировка коллекции
This file contains 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
public class Sort | |
{ | |
public static Map<Double, String> map = new TreeMap<Double, String>(Collections.reverseOrder()); | |
public static void main(String args[]) | |
{ | |
// create linked list object | |
LinkedList<Integer> list = new LinkedList<Integer>(); | |
// populate the list | |
list.add(-28); | |
list.add(20); | |
list.add(-12); | |
list.add(8); | |
// create comparator for reverse order | |
Comparator<Integer> cmp = Collections.reverseOrder(); | |
// sort the list | |
Collections.sort(list, cmp); | |
System.out.println("List sorted in ReverseOrder: "); | |
for (int i : list) | |
{ | |
System.out.println(i + " "); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment