sed -E, 109 99 bytes
h;s:.:0:g;G;s:0\n(.*): -\1-\n:
:l;s:(.)(.*)-(.)(.*)-(.*):\2-\4-\5+ \3\1\2:;tl
s:. 0* ::g;s:[^ ]* ::
Each line of the input is considered a separate number. Try it online.
Explanation:
h; | copy the original string to the temporary buffer
s:.:0:g; | substitute all digits with zeroes
G; | append the original string to the substituted one
s:0\n(.*): -\1-\n: | '0…000\n6…987' -> '0…00 -6…987-\n'
|
:l; | main loop start
s:(.)(.*)-(.)(.*)-(.*):\2-\4-\5+ \3\1\2:; | cut the next digit from the number, append with zeroes and add to the back
tl | loop if the substitution hasn`t converged yet
|
s:. 0* ::g; | remove all zero terms
s:[^ ]* :: | remove everything up to the first space
…still plenty of room for optimization.