Dave's Brain

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

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.