AFAIK Windows keeps a z-order for open windows, so I guess that raising a group should respect how they are actually stacked.
I don't really know the internals of Windows, so I can't say how it would work for minimized app.
By the way, let's say your windows are stacked this way:
A, B, C1, C2, C3, D, where leftmost means the top of the stack (topmost window) and C1,C2,C3 belong to the same app;
when you click the C group on the taskbar you'd get C1, C2, C3 raised and the stack would now look like:
C1, C2, C3, A, B, D
Now, suppose you give focus to C3 by clicking it: C3 is raised and the stack it is now
C3, C1, C2, A, B, D
Now you raise, A, B, D in sequence, you get
D, B, A, C3, C1, C2 (remember it's a stack)
Finally suppose you click again the C group, you'll have
C3, C1, C2, D, B, A
I hope it is clearer. Yeah, now that I've explained it all it sounds much harder to do than I first thought
A quick and dirty solution would be
not to respect the z-order and raising, say, by alphabetical order; but I suppose then it'd be more of an hassle, as you rightly point out.