If $A$ and $B$ are nonempty sets, prove that $A \times B = B \times A$ if and only if $A = B$ 
If $A$ and $B$ are nonempty sets, prove that $A \times B = B \times A$ if and only if $A = B$.

Proving the first direction of this is easy. That is, if $A = B$ then it is obvious that $A^2 = A^2$. I am wondering how to prove the other direction now. Maybe proving it by contradiction will be easier than directly.

Simple enough:
For each $a$ in $A$, choose a $b$ in $B$.  Then $(a,b)$ is in $A\times B$.  Since $A\times B = B\times A$ we have $(a,b)$ is in $B\times A$.  So $a$ is in $B$.
This shows that $A$ is a subset of $B$.  Interchanging $A$ with $B$, we also infer $B$ is a subset of $A$.  So $A=B$.
