Sorting slots: Include a comparison on old_code

to make it deterministic.