The XD documentation itself doesn’t seem to document what happens when you group things, but it appears that a group (
command.group()) pulls all objects in the group to the Z-order of the highest member of the group.
This kind of behavior is very interesting to those of us who are using grouping from the API, and it would be great to have official documentation for what happens in those cases.
I also noticed that if you group objects across artboards, that grouping pulls all the elements under the artboard of the first (?) object in the group.