It literally sorted itself out eventually. Most of the stuff showed up in the sorters that I put out, and some things sorted themselves back into the right folders. I was sweating there for a few hours, though.
Oops. I accidentally dumped my entire inventory of no-copy DFS objects into a scripted sorting prim; more than 1500 objects went in. For most of them, I had picked up the “target sortboxes” so I put them back out.