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$?

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.
