Taken apart in order of acid strength

A separating funnel question is not something to memorise. It falls out of acid and base strength. Turn into a salt and it dissolves and drops into the water layer. Stay neutral and it remains in the ether. That is the whole rule.

Press the reagents in the steps panel from the top down and the layers separate in the funnel. Switch the chart panel to acid strength to see which boundary was just crossed. Panels can be dragged by their header and resized from any edge or corner, and double-clicking a title pins it to the top right.

The mixture holds aniline, benzoic acid, phenol and nitrobenzene. Aniline is the only base, so hydrochloric acid salts it and it drops through. The other three are acidic or neutral and do not move.

Sodium hydrogen carbonate comes next, and only benzoic acid moves. To be salted by it a compound has to be a stronger acid than carbonic acid, and a carboxylic acid is while a phenol is not. Switch the chart to acid strength and the three sit in exactly that order.

Sodium hydroxide finally salts the phenol. It is the stronger base, so it reaches acids weaker than carbonic acid. What is left is nitrobenzene, neither acid nor base, which no reagent can salt.

Reversing the order fails. Sodium hydroxide first would take benzoic acid and phenol into the water together. The bases are used weakest first so that one boundary is crossed at a time.