I would like to have a c.g.c.c.Multimap that is sorted based on keys only. The values shouldn\'t be sorted. I\'ve tried to build something with guava\'s T
How about this:
public static Multimap indexOnScore(Iterable i) {
Multimap m = Multimaps.index(i, myObjectToScore());
Multimap sortedKeys = Multimaps.newMultimap(
Maps.>newTreeMap(),
new Supplier>() {
@Override
public Collection get() {
return Lists.newArrayList(); // Or a Set if appropriate
}
}
);
sortedKeys.putAll(m);
return sortedKeys;
}
There would be the overhead of creating two separate Multimaps in this case, though.