Created
October 16, 2022 14:36
-
-
Save rmg007/31be816d102dcb042d799ecbded4c2d8 to your computer and use it in GitHub Desktop.
Sort String List Using Case Insensitive Order Comparator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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