Thanks Chopin - I had not thought about or seen that emphasis on the integration variables.
The rule then seems be that bra-ket has common integration variables, and ket-bra different ones, so <f|g><a|b> becomes f*(x) g(x) a*(y) b(y) whichever way they are grouped.
For the operator, here...