Specifying the shape in the mixture should fix the error:
mix = pm.Mixture('mix', w=w, comp_dists = comp_dists, shape=(n, 2))
However, a few point you should fix:
1, using tt.sort does not impose ordering from the sampler standpoint, as the logp is not modified with tt.sort. You should use an Ordered transformation (still WIP PR on Github, but you can search the discourse for some more informaiton)
2, CB = pm.Deterministic.dist('CB', tt.sort(mix, axis=1)) is not allow - I guess you meant CB = pm.Deterministic('CB', tt.sort(mix, axis=1)) However, sorting the mixture is pretty weird choice - i would suggest removing it.