The idea borrowed from this. The first Wasserstein distance between the distributions $u$ and $v$ is:
$$ l_1 (u, v) = \inf_{\pi \in \Gamma (u, v)} \int_{\mathbb{R} \times \mathbb{R}} |x-y| \mathrm{d} \pi (x, y) $$
where $\Gamma(u,v)$ is the set of (probability) distributions on $\mathbb{R}\times \mathbb{R}$ whose marginals are and on the first and second factors respectively.
If $U$ and $V$ are the respective CDFs of $u$ and $v$, this distance also equals to:
$$ l_1(u, v) = \int_{-\infty}^{+\infty} |U-V| $$
Suppose we wanna move the blocks on the left to dotted-blocks on the right, we wanna find the "energy" (or metric) to do that.
Energy = $\Sigma$ weight of block x distance to move that block.
Suppose that weight of each block is 1. All below figures are copied from this.
There are 2 ways to do that,
2 ways of moving blocks from left to right.
Above example gives the same energies ($42$) but there are usually different as below example,