Sorting within SortingGroup is made by hierarchy ?

Let there be 2 Sprite Renderers that are on on the same sorting layer and have the same sorting order.
Usually, these sprites would be sorted based on their position in the world, and whatever sorting axis you set in the project’s graphic settings.
Now put these two inside a Sorting Groups : they will no longer be sorted by their world position, but by their order in the hierarchy. (Similar to how UI is sorted).

I couldn’t find any documentation on that matter, so is this intended or is it some sort of bug ?
One thing that leads me to think this isn’t intended is that when changing the hierarchy order, the changes in the sorting won’t take effect immediately, you’d need to save the scene first, or touch the sorting index/layer.

Working on an isometric project, I rely heavily on depth-based sorting. I can do with it, but I still wished I could sort sprite this way within a sorting group.

3275896–253281–SortingGroups.zip (959 KB)

Edited: OP clarified the specifics of the question

They shouldn’t sort by hierarchy order, they should sort by their configured Sorting Layer and Sorting Order, or depth by default, as is expected of non-SortingGrouped SpriteRenderers

I am specifically speaking about object that have the same Sorting Layer and Sorting Order.
To boil it down, are you saying that such objects should sort by depth even inside a Sorting Group?
Of course I do mean “still separately from everything outside the SortingGroup”, but I’m specifically asking about the inner sorting of the group.

After doing some testing, it appears that what you’ve described is the behavior I’m seeing as well. I agree that this seems like unexpected behavior.

Recently I did meet a specific case where the inner sorting wasn’t hierarchic any more, just completely anarchic.
Seems like I’m gonna send a bug report anyway, it’s just gonna be a very lengthy report since I don’t know whether the bug starts before or after that hierarchy-sorting business…

i found a case maybe like yours:
two SortingGroup contains some SpriteRenderers, both have different orders;
in editor it is show good,
but when running, and add new SpriteRender into one of them, the sort maybe will has problem;

now my approach is disable the SortingGroup and enable the SortingGroup, the sort will restore ok;

Just FYI the dynamically spawned object sorting bug was reproduced and fixed for Unity 2017.3