The best way to prevent walnuts from sinking in a cake is to slightly warm them in the oven preheated to 350F degrees. Then toss the walnuts in flour and only then add them to the cake batter.