I was thinking of something like [this gist](https://gist.github.com/mwmiller/9965778).  Of course the ordering ends up being non-deterministic, but you're unlikely to care if you don't edit it by hand  (or about it being pretty!)

On the other hand, I see you have some cases where next leads to an array of things, so I don't know if it gets insanely messy or (as you point out) has such infrequent changes that you just want to forget it.