I feel like this is cheating.
order by count, if use the inbuilt api will use if statements.
even if use the stream api.
even the split function uses if statements; probably somechar == nextchar or something like that
but I believe this problem is pretty to hard to solve without an if statement.
but you can use mathematics, but you might need an if statement, havent thought about it too much