I have this code to take a map and sort it by key I then reverse the map to get them with the largest elements first.
Ordering<String> valueComparator =
Ordering.natural().onResultOf(Functions.forMap(WordMap))
.compound(Ordering.natural());
WordMapSorted = ImmutableSortedMap.copyOf(WordMap,
Collections.reverseOrder(valueComparator));
I'd like to know two things
How can I get only the keys with a value above 10? I feel like given the sorting with guava there should be an easy way to specify a cutoff point (since once you reach a value below the threshold, you simply get all the items before it)
How can I get the first 100 entries in the map (still in the form of a map). I know I can just get an array of keys and get the first 100, but I want the first 100 map entries. I know that normally a map has no order, but in this case it was sorted and made immutable so it does have order.