This may have been asked before but it's difficult to search for. Suppose that $|A|=n$ and that $R$ is a total order on $A$ (not a strict order). Define $g:A \to I_n$ by
$$ g(a) = |\{x \in A ~|~ xRa\}| \,, $$
where $I_n = \{1, 2, 3, \ldots, n\}$. Prove that $\forall a,b \in A (aRb \leftrightarrow g(a) \leq g(b) )$.
I can easily show the $(\to)$ direction but I cannot seem to prove that $g(a) \leq g(b) \to aRb$.
If $X = \{x \in A ~|~ xRa\}$ and $Y = \{x \in A ~|~ xRb\}$ then $g(a) = |X|$ and $g(b) = |Y|$. Then suppose that $|X| \leq |Y|$. If I could show that $X \subseteq Y$ then the result follows immediately: since $a \in X$ (since $R$ is reflexive) then $a \in Y$ (since $X \subseteq Y$) so $aRb$, but I can't seem to be able to show this, though I'm confident that I'm missing something simple.
Any help with this would be much appreciated. Thanks!
HINT: Let $S$ be the strict version of $R$, and show that if $a\mathrel{S}b$, then $g(a)<g(b)$. If $a\not\mathrel{R}b$, then $b\mathrel{S}a$, so ... ?