Browse - Programming Tips - Java: How can I do a case-insensitive sort of ArrayListString ?

Date: 2017nov24
Language: Java

Q. Java: How can I do a case-insensitive sort of ArrayList<String> ?

A.

ArrayList<String> myArray = new ArrayList<>(); ... Collections.sort(myArray, String.CASE_INSENSITIVE_ORDER); // Case-insensitive sort
Or
Collections.sort(myArray, Collator.getInstance());