Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rmg007/31be816d102dcb042d799ecbded4c2d8 to your computer and use it in GitHub Desktop.
Save rmg007/31be816d102dcb042d799ecbded4c2d8 to your computer and use it in GitHub Desktop.
Sort String List Using Case Insensitive Order Comparator
import java.util.ArrayList;
import java.util.List;
public class SortStringListUsingCaseInsensitiveOrderComparator {
public static void main(String[] args) {
List<String> list = new ArrayList<>(List.of("Byyyyyyyyyyyy", "Dww", "Cxxxxxx", "az"));
list.sort(String.CASE_INSENSITIVE_ORDER);
//output: [az, Byyyyyyyyyyyy, Cxxxxxx, Dww]
System.out.println(list);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment