Refactor #sort_link to extract mutation and order-dependent

code into a single `initialize!` method and reduce what was previously
a large, 100-line method with values mutating from start to finish,
into a 5-line method that calls other small, order-independent,
mutation-free methods.

Consider this an experiment. It could be much better. There is a bit
more to do and improve, and a few places where I think the code can be
optimized to run faster.

The two form_helper methods could probably benefit from much better
documentation in the code itself, to help developers who would like to
improve it and submit PRs.