1 package org.paneris.jammyjoes.mvp; 2 3 import java.util.ArrayList; 4 import java.util.Collections; 5 import java.util.Comparator; 6 import java.util.HashMap; 7 import java.util.List; 8 9 public class ReverseCollectionSorter { 10 11 public List sort(HashMap map) { 12 List result = new ArrayList(map.values()); 13 Collections.sort(result, new ReverseComparitor()); 14 return result; 15 } 16 17 private class ReverseComparitor implements Comparator { 18 19 public int compare(Object o1, Object o2) { 20 Comparable c1 = (Comparable)o1; 21 Comparable c2 = (Comparable)o2; 22 return c2.compareTo(c1); 23 } 24 25 } 26 }