开发者

Case Insensitive sorting using Google Guava

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜