Suppose I have a list (or Set):
List testList = Lists.newArrayList(\"assocX\",\"srcT\",\"destA\",\"srcX\", \"don\'t care Y\", \"garbage\", \"sr
Have a look at This Google Collections example.
Function getNameFunction = new Function() {
public String apply(Fruit from) {
return from.getName();
}
};
Ordering nameOrdering = Ordering.natural().onResultOf(getNameFunction);
ImmutableSortedSet sortedFruits = ImmutableSortedSet.orderedBy(
nameOrdering).addAll(fruits).build();
Though this, admittedly, returns a Set.