Desmos, 9396 bytes
C=C=sgn(L[2...]-L)^2
g(L)=∑_{n=1}^{[1...C.count]}C[n]
f(A,B)=sort(join(A,B),join(0,g(A),0,g(B)))
Ok this can probably be improved somehow but for now this is good enough.
Try It On Desmos!Try It On Desmos!
Try It On Desmos! - PrettifiedTry It On Desmos! - Prettified