Let $G$ and $H$ be groups. Prove that $G\times H$ is isomorphic to $H\times G$ "A Book of Abstract Algebra" by Dr. Pinter presents this exercise:

Let $G$ and $H$ be groups. Prove that $G\times H$ is isomorphic to $H\times G$.

My understanding is that I need to find a function $f$, such that $f(G\times H) = H\times G$.
My initial thought was to rely on the commutative property of multiplication. In other words, the function $f$ would be the identity function.
But that does not seem right. Please point me in the right direction.
Note - I looked at related questions, but did not recognize them (perhaps due to terms that I don't understand) to answer this question.
 A: To prove two groups $A$ and $B$ are isomorphic, you need to find an isomorphism from $A$ to $B$, not just a function. An isomorphism $f:A\to B$ is a function which is


*

*A homomorphism, meaning $f(a_1a_2)=f(a_1)f(a_2)$, for any $a_1,a_2\in A$.

*Injective, meaning that $a_1\neq a_2$ implies $f(a_1)\neq f(a_2)$, for any $a_1,a_2\in A$.

*Surjective, meaning that for any $b\in B$, these is an $a\in A$ for which $f(a)=b$. 


In this case, you want to find an isomorphism $f:G\times H\to H\times G$. You cannot use the "commutativity of multiplication," since the cartiesian product, $\times$, of sets is not commutatve. 
A general element of $G\times H$ looks like $(g,h)$, where $g\in G$ and $h\in H$. Similarly, elements of $H\times G$ look like $(h,g)$. So, the only difference between these groups is whether or not the ordered pairs have the $G$ element on the right or left. This suggests that the isomorphism you want just switches the order of the ordered pairs. So, define $f:G\times H\to H\times G$ by
$$
f((g,h))=(h,g)
$$
and prove that $f$ is an isomorphism.
A: Try the function $f:(g,h) \to (h,g)$.
