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
why dont use something like this, its easier and java 8
listOfABCElements = {true, false, false, true, true};
listOfABCElements.stream().sorted(Comparator.comparing(Abc::isClickable,Comparator.reverseOrder()).collect(Collectors.toList());
output: true,true,true,false,false
reverseOrder is for order first true and after false, in other case falses goes first
listOfABCElements.stream().sorted(Comparator.comparing(Abc::isClickable).collect(Collectors.toList());
output: false,false,true,true,true