I have the list of persons and if the list of Input is 3,0,2,7,0,8
I want the output to be 2,3,7,8,0,0
With the following code, i can sort only non zero numbers to get 2,3,7,8 as output.
sortedList = personList.stream()
.filter(Person -> Person.getAge()>0)
.sorted(Comparator.comparingInt(Person::getAge))
.collect(Collectors.toList());
zeroList=personList.stream()
.filter(Person -> Person.getAge()==0)
.collect(Collectors.toList());
sortedList.addAll(zeroList);
Can the above two statements be merged into a single statement?