Finite direct products are isomorphic up to permutation of the factors

Let $G_i$ be groups for $1 \leq i \leq n$ and let $\pi \in S_n$. Prove that the map $\varphi_\pi : \times_{i=1}^n G_i \rightarrow \times_{i=1}^n G_{\pi^{-1}(i)}$ given by $(\varphi_\pi(g))_i = g_{\pi^{-1}(i)}$ for all $g = (g_i)$ is an isomorphism (so that changing the order of the factors in a finite direct product does not change the isomorphism type).

We need to show that $\varphi_\pi$ is a bijective homomorphism.

1. Homomorphism: Let $g = (g_i)$ and $h = (h_i)$. Then $(\varphi_\pi(gh))_i = g_{\pi^{-1}(i)} h_{\pi^{-1}(i)}$ $= (\varphi_\pi(g))_i (\varphi_\pi(h))_i$ for each $i$; hence $\varphi_\pi(gh) = \varphi_\pi(g) \varphi_\pi(h)$.
2. Injective: Let $g = (g_i), h = (h_i) \in \times_{i=1}^n G_i$ such that $\varphi_\pi(g) = \varphi_\pi(h)$. Then for each $i$, we have $g_{\pi^{-1}(i)} = h_{\pi^{-1}(i)}$. Because $\pi$ is a permutation of $\{1,2,\ldots,n\}$, we have $g_i = h_i$ for each $i$; hence $g = h$. Thus $\varphi_\pi$ is injective.
3. Surjective: Let $g = (g_{\pi^{-1}(i)}) \in \times_{i=1}^k G_{\pi^{-1}(i)}$. It is clear that, with $g^\prime = (g_i)$, we have $\varphi_\pi(g^\prime) = g$. Thus $\varphi_\pi$ is surjective.