Sorting string value in a case-insensitive manner in Java 8

前端 未结 6 920
春和景丽
春和景丽 2021-01-01 08:57

How do I sort string values in case-insensitive order in the following?

List listofEmployees = Arrays.asList(
    new Employee(1, \"aaa\", Ar         


        
6条回答
  •  我在风中等你
    2021-01-01 09:43

    You can specify it as the second argument to ignore cases:

    Comparator.comparing(Employee::getName, String::compareToIgnoreCase).reversed()
    

提交回复
热议问题