### Question:
Counter extends java.util.TreeMap<Type, Integer> { public List<Type> keyList(Order order) { List<Type> list = new ArrayList<Type>(keySet()); if (order == Order.ASCENDING) { Collections.sort(list); } else if (order == Order.DESCENDING) { Collections.sort(list, Collections.reverseOrder()); } else if (order == Order.ASCENDING_VALUE) { Collections.sort(list, new KeyComparator()); } else if (order == Order.DESCENDING_VALUE) { Collections.sort(list, Collections.reverseOrder(new KeyComparator())); } else if (order == Order.LEXICOGRAPHIC && list.size() > 0 && list.get(0).getClass().equals(String.class)) { Collator collator = Collator.getInstance(); collator.setStrength(Collator.TERTIARY); collator.setDecomposition(Collator.FULL_DECOMPOSITION); Collections.sort(list, collator); } return list; }  Counter<Type> add(Type object, int value); Counter<Type> set(Type object, int value); Counter<Type> inc(Type object); Counter<Type> dec(Type object); Counter<Type> add(Counter<Type> counter); Counter<Type> add(Type[] objects); int value(Type object); int maxValue(); int total(); @Override void clear(); List<Type> keyList(Order order); @Override String toString();  }### Answer:
@Test public void testKeyList() { System.out.println("keyList"); Counter<Integer> instance = new Counter<Integer>(); instance.add(1, 6); instance.add(2, 3); instance.add(3, 1); instance.add(4, 5); Integer[] expResult = {3, 2, 4, 1}; Integer[] result = new Integer[4]; List<Integer> list = instance.keyList(Counter.Order.ASCENDING_VALUE); System.out.println(list); list.toArray(result); assertArrayEquals(expResult, result); }