Skip to content

Instantly share code, notes, and snippets.

@sadedv
Last active March 8, 2016 12:45
Show Gist options
  • Save sadedv/280f3f43e0948449c2d4 to your computer and use it in GitHub Desktop.
Save sadedv/280f3f43e0948449c2d4 to your computer and use it in GitHub Desktop.
Обратная сортировка коллекции
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