I was reading about how Euler derived his famous identity, $e^{i{\pi}}$. It said that it was discovered when Euler took the Taylor Expansion for $e^x$, and he multiplied the $x$ by $i$, and it gave him the formula: $$e^{ix}=1+ix-\frac {x^2}{2!}-\frac{ix^3}{3!}+\frac{x^4}{4!}...$$ He then separated the series by imaginary and real parts, and found $$e^{ix}=(1-\frac{x^2}{2!}+\frac{x^4}{4!}-...)+i(x-\frac{x^3}{3!}+\frac{x^5}{5!}-...)$$ He then recognized the two series as taylor series for sine and cosine, $$e^{ix}=\cos x+{i}\sin x$$
Now, my question is, why was he able to split up the infinite series like that? From my understanding, if you change the order of terms in an infinite series you'll change the value of the sum, so why was he able to?