Adds the subobject part to the sort key.

Based on the patch https://gerrit.wikimedia.org/r/#/c/70047/4

This needs some test, but before that someone needs to explain what this achieves and why this is the desired way to do it. Because I have just c/p stuff from the original patch.