Solution to Abstract Algebra by Dummit & Foote 3rd edition Chapter 1.1 Exercise 1.1.22
Let $G$ be a group and let $x,g \in G$. Prove that $|x| = |g^{-1} x g|$. Deduce that $|ab| = |ba|$ for all $a,b \in G$.
Solution: First we prove a technical lemma:
Lemma.For all $a,b \in G$ and $n \in \mathbb{Z}$, $(b^{-1} a b)^n = b^{-1} a^n b$.
The statement is clear for $n = 0$. We prove the case $n > 0$ by induction; the base case $n = 1$ is clear. Now suppose $(b^{-1} a b)^n = b^{-1} a^n b$ for some $n \geq 1$; then $$(b^{-1} a b)^{n+1} = (b^{-1} a b) (b^{-1} a b)^n = b^{-1} a b b^{-1} a^n b = b^{-1} a^{n+1} b.$$ By induction the statement holds for all positive $n$.
Now suppose $n < 0$; we have $$(b^{-1} a b)^n = ((b^{-1} a b)^{-n})^{-1} = (b^{-1} a^{-n} b)^{-1} = b^{-1} a^n b.$$ Hence, the statement holds for all integers $n$. $\blacksquare$
Now to the main result. Suppose first that $|x|$ is infinity and that $|g^{-1}xg| = n$ for some positive integer $n$. Then we have $$(g^{-1} x g)^n = g^{-1} x^n g = 1,$$ and multiplying on the left by $g$ and on the right by $g^{-1}$ gives us that $x^n = 1$, a contradiction. Thus if $|x|$ is infinity, so is $|g^{-1} x g|$. Similarly, if $|g^{-1} x g|$ is infinite and $|x| = n$, we have $$(g^{-1} x g)^n = g^{-1} x^n g = g^{-1} g = 1,$$ a contradiction. Hence if $|g^{-1} x g|$ is infinite, so is $|x|$.
Suppose now that $|x| = n$ and $|g^{-1} x g| = m$ for some positive integers $n$ and $m$. We have $$(g^{-1} x g)^n = g^{-1} x^n g = g^{-1} g = 1,$$ so that $m \leq n$, and $$(g^{-1} x g)^m = g^{-1} x^m g = 1,$$ so that $x^m = 1$ and $n \leq m$. Thus $n = m$.
Now let $a$ and $b$ be arbitrary group elements. Letting $x = ab$ and $g = a$, we see that $$|ab| = |a^{-1}aba| = |ba|.$$