Sort an ArrayList by primitive boolean type

前端 未结 8 835
北恋
北恋 2020-12-09 16:08

I want to sort my ArrayList using a boolean type. Basically i want to show entries with true first. Here is my code below:

Abc.java

8条回答
  •  时光说笑
    2020-12-09 16:48

    It is also possible that way.

    myList.sort((a, b) -> Boolean.compare(a.isSn_Principal(), b.isSn_Principal()));
    

提交回复
热议问题