Are there convenience methods for sorting arrays and collections that support method chaining in Java or popular open source utility libraries such as Guava or Apache-Commons? Something that I could throw into a snippet like this:
private static final List<String> myStrings = collections.unmodifiableList(
SortUtils.sortList(
Arrays.asList(new String["b","a"])
)
);
Then myStrings would contain “a”, and “b” (in that order).
I could write methods like this myself, but I don’t want to re-invent the wheel if they are already available in the libraries that I use.
You might be looking for
Ordering.sortedCopyin Guava, but that’s fluent in the comparator, not the collection.Something fluent on the list might appear in Guava’s
FluentIterable, probably coming out in Guava release 12.