Give an example of two distinct sets $A$ and $B$ such that $A \times B = B \times A$ This is a question from my textbook. The book gives the answer $A = \varnothing$ and $B = \{1\}$.
The definition of $A \times B$ is $\{(a,b): a \in A \land b \in B\}$.
But if $A = \varnothing$, what could be in it?
Even if it's $(\varnothing, 1)$ & $(1, \varnothing)$, how do you compare $\varnothing$ and $1$?
 A: If there is an element of $\emptyset \times B$, then there is an element of $\emptyset$, but it is a contradiction. Thus $\emptyset \times B=\emptyset$. You can show that $B\times \emptyset=\emptyset$ in similar way.
A: You are on the right track as if one of the two sets is empty so is the cartesian product. Formally 
$$
\emptyset\in \{A,B\}\Longrightarrow A\times B=\emptyset 
$$
then you can choose $A=\emptyset,B=\{1\}$.
One can, moreover, show that all the solutions are of the form $(A=\emptyset,B \not=\emptyset)$ or $(A\not=\emptyset,B=\emptyset)$.  
If you want to "feel" why it is so, you have two reasons. 
1) Every cartesian products comes with its two projections $pr_1,pr_2$ such that 
$$
pr_1((x,y))=x;\ pr_2((x,y))=y
$$ 
so, if you have any element in $A\times B$, you must have $A\not=\emptyset$ and  $B\not=\emptyset$
2) As remarked by Henry Swanson in the comments $|A \times B| = |A| \cdot |B|$ then, again, 
$$
A\times B=\emptyset \Longleftrightarrow A=\emptyset\mbox{ or }  B=\emptyset
$$
Hope it helps.
A: Look at the definition literally and thouroughly
$\emptyset \times B=\{(a,b)|a\in \emptyset \land b \in B\} $
As there are no $a\in \emptyset  $ there are no $(a,b)\in \emptyset\times B $.
So $\emptyset \times B=\emptyset$.
Likewise $B \times \emptyset =\emptyset $.

Furthmore if $A\ne \emptyset  $ and $B \ne \emptyset  $ then either there exists a $a \in A;a \not \in B $ or there is a $b\in B;b\not \in B $.  Or both.  
Without loss of generality we will assume there is an $a\in A; a\not \in B $.  Let $b\in B $ (any element;nothing specific).  Then $(a,b) \in A\times B $ but $(a,b) \not \in B\times A $ (as $a\not \in B $)
So we can prove if $A\times B=B\times A$ then either $A=B $ or one of the sets is empty.
