Case Insensitive Sorting Using Google Guava

Current I use the following 2 pieces of code in two different places to create a sorted, immutable list.

return Ordering.natural().immutableSortedCopy(iterable); 

and

 return Ordering.usingToString().immutableSortedCopy(machines); 

However, this makes the "ordering" case sensitive .

How to use guis apis to make a sorted immutable unordered <? >

+7
source share
1 answer

I believe that you will need to use the from method with a String.CASE_INSENSITIVE_ORDER comparator like this.

 return Ordering.from(String.CASE_INSENSITIVE_ORDER).immutableSortedCopy(iterable); 
+15
source

All Articles