Current I am using the following 2 pieces of code in 2 different places to create a开发者_StackOverflow中文版 sorted, immutable list.
return Ordering.natural().immutableSortedCopy(iterable);
and
return Ordering.usingToString().immutableSortedCopy(machines);
However, this makes the 'ordering' case sensitive.
How do I use the guava apis to make a case-insensitive sorted immutable list?
I believe you will need to use the from method with the String.CASE_INSENSITIVE_ORDER
comparator, like this.
return Ordering.from(String.CASE_INSENSITIVE_ORDER).immutableSortedCopy(iterable);
精彩评论