What you wrote, $x-y=|d|=y-x$ is incorrect. Take x=1 an y=2 for example. $1-2\
eq2-1$
What you probably meant to say is this. ($d$ is positive)
$$|x-y|=d=|y-x|$$
Here is my explanation:
$$x-y=-(-x)+(-y)$$ $$x-y=-((-x)+y)$$ $$x-y=-(y-x)$$
Now, in simple terms, the absolute value of a a number just makes it posotive. Because of that, for any variable $n, |-n|=|n|$. Therefore:
$$|-(y-x)|=|y-x|$$ so $$|x-y|=|y-x|$$