Every polish space $X$ has a total ordering that is polish as a subset of $X^2$ Let $X$ be a polish space (i.e. second countable and completely metrizable). I would like to show that there exists a total ordering $<_X$ such that
$$
\{(x,y) \in X^2 : x <_X y\}
$$
is also Polish (equivalently, I could show that this set is $G_\delta$).
This problem was presented with a hint. Let $(U_n)_{n\in\mathbb{N}}$ be a basis for the topology on $X$ and consider the injection $i : X \to 2^\mathbb{N}$ given by $i(x) = (x_n)_{n\in\mathbb{N}}$ where
$$
x_n = \begin{cases}
1 &\text{if } x \in U_n \\
0 &\text{if } x \not\in U_n.
\end{cases}
$$
Since $2^\mathbb{N}$ is homeomorphic to the Cantor set $\mathcal{C}$ (via a homeomorphism $\phi :  2^{\mathbb{N}} \to \mathcal{C} $ ), I considered setting $x <_X y$ iff $\phi\circ i (x) < \phi\circ i (y)$. However, I am unsure how to show that
$$
\{(x,y) \in X^2 : x <_X y\}
$$
is Polish (or $G_\delta$), or if this is the right ordering to consider.
I would appreciate any ideas!
 A: Take $\phi(b_1,b_2,\ldots)=\sum_{j \ge 1} 2 b_j 3^{-j}$ where $b_j \in \{0,1\}$, so the induced ordering on $\{0,1\}^{\mathbb N}$ is lexicographic.
Endow $\{0,1\}^n$ with the lexicographic ordering, i.e., for $b,d \in \{0,1\}^n$, we write $b \le d$ iff either $b=d$, or
$b_{i*}<d_{i^*}  $,
where $i^*=i^*(b,d)=\min\{i \ge 1: b_i\ne d_i\}$.
For every string $b=(b_1,\ldots,b_n) \in \{0,1\}^n$, write
$L_b:=\{x \in X: (x_1,\ldots,x_n) \le b\}$. Recall that every closed set in a metric space is a $G_\delta$ set.
By enumerating over the value of $i^*(x,b)$, we see that $L_b$ is a $G_\delta$ set in $X$, as a finite union of $G_\delta$ sets. Similarly,  $L_b^c$ is a $G_\delta$ set in $X$. Therefore, $L_b \times L_b^c$ is a $G_\delta$ set in $X^2=X \times X$, whence so is
$$A_n:=   \bigcap_{b \in \{0,1\}^n} \Bigl((L_b \times X) \cup (X \times L_b^c) \Bigr)\,  $$
for every $n$.
Next, let $\Delta=\{(x,x): x \in X\}$ denote  the diagonal in $X^2$. Observe that
$$A_n=\{(x,y)\in X^2: (x_1,\ldots,x_n) \le (y_1,\ldots,y_n) \}\,$$
so
$$ \{(x,y) \in X^2 : x <_X y\}= \cap_{n \ge 1} A_n \setminus \Delta \,$$
is also a $G_\delta$ set in $X^2$.
