How can I sort a list of maps by value of some specific key using Java 8?

前端 未结 6 2224
情话喂你
情话喂你 2020-12-18 02:46

How can I sort a List of Map using Java 8? The map contains a key called last_name, and the value associated wit

6条回答
  •  一生所求
    2020-12-18 02:49

    You can override de compare method of the Collection. Here is an example: https://www.mkyong.com/java8/java-8-lambda-comparator-example/

    You will have to compare the last_name of the objects, and do not forget to handle the null properly.

提交回复
热议问题