is it possible to constrain the optimization further to avoid crossing of the connector lines? its practical application is shown below where the current setup (allowing to move along y only) dose not preserve the order of the original labels along the y direction.

ggrepel appears to have such a constraint?
https://ggrepel.slowkow.com/articles/examples#align-labels-on-the-left-or-right-edge