Skip to content

Instantly share code, notes, and snippets.


bytecodeman/LoadArrayList.txt Secret

Last active Nov 28, 2019
What would you like to do?
Supplemental Code for Names App V2.0
int count = 0;
for (Map.Entry<String, Integer> entry : list.entrySet()) {
String key = entry.getKey();
int value = entry.getValue();
if (count >= top)
topNames.add(new Name(key, value));
private static <K, V extends Comparable<V>> TreeMap<K, V> sortByValues(Map<K, V> map) {
Comparator<K> valueComparator = new Comparator<K>() {
public int compare(K k1, K k2) {
int compare = map.get(k1).compareTo(map.get(k2));
return -compare;
TreeMap<K, V> sortedByValues = new TreeMap<>(valueComparator);
return sortedByValues;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.