Direct product of groups is essentially commutative

Let $A$ and $B$ be groups. Prove that $A \times B \cong B \times A$.

We know from set theory that the mapping $\varphi : A \times B \rightarrow B \times A$ given by $\varphi((a,b)) = (b,a)$ is a bijection with inverse $\psi : B \times A \rightarrow A \times B$ given by $\psi((b,a)) = (a,b)$. Also $\varphi$ is a homomorphism, as we show.

Let $a_1, a_2 \in A$ and $b_1, b_2 \in B$. Then $\varphi((a_1,b_1) \cdot (a_2,b_2)) = \varphi((a_1a_2, b_1b_2))$ $= (b_1b_2, a_1a_2)$ $= (b_1,a_1) \cdot (b_2,a_2)$ $= \varphi((a_1,b_1)) \cdot \varphi((a_2,b_2))$.

Hence $A \times B \cong B \times A$.