You can use Comparator.comparing(...).thenComparing(...) to sort by more than one attribute. For sorting favourites first, you can sort by that attribute, but then have to reverse the result, as false sorts before true. Assuming that you want to sort just by whether the count is > 0, and not by the actual value of the count:
List<Person> persons = Arrays.asList(
new Person("p1", 2, true),
new Person("p2", 0, false),
new Person("p3", 0, true),
new Person("p4", 1, false),
new Person("p5", 3, true));
persons.stream().sorted(Comparator
.comparing(Person::isFavorite).reversed()
.thenComparing(p -> p.getCount() == 0))
.forEach(System.out::println);
Result:
Person(name=p1, count=2, favorite=true)
Person(name=p5, count=3, favorite=true)
Person(name=p3, count=0, favorite=true)
Person(name=p4, count=1, favorite=false)
Person(name=p2, count=0, favorite=false)
Note that the final count == 0 condition is redundant (assuming that count can not be < 0)
Or sort by count directly and reverse once at the end; this will sort p5 before p1 in the example:
persons.stream().sorted(Comparator
.comparing(Person::isFavorite)
.thenComparing(Person::getCount).reversed())
.forEach(System.out::println);
Comparator.comparing(...).thenComparing(...)?countin descending order.