For mobile too, not only desktop.
When I post I mean for both.
Similar will be for phone, main stacks will stay in front of every era and after the stacks all injured units, that will be he best variant for both devices, no need to hide, other tabs, whatever, is good for everyone, and GvG sieges aswell for pc players.
If dev's share the API code logic used for stacking and separating the damaged units, it will be much useful to suggest perfect solution. Currently, all are asking to move the damaged units to last slot. But they are grouped based on unit type to position in every tab. Visually what you mention is very correct, just checking the possibility with the grouping and sorting of unit type based on age.
Let's take small dive now,
Considering All units tabs with two different age units stacked, grouped and sorted based on unit type sequentially. Whenever player opens the army window, the action of stacking/sorting take place. Here, if you want to move only damaged units out of the actual sorting order position, unit type needs to be something else. Unfortunately, ours is same unit type which has already sorted with rest of the different unit types. I don't get any ways of implementing this without removing the initial sorting and grouping order of units presented in the army window.
Let's say, a b are the two ages with 1 2 units category type with x20 unit each and rogues too
a1 a2 a3 - latest age
b1 b2 b3 - previous age
R - rogues
Now grouping, sorting and stacking.
[a1] [a2] [a3] [b1] [b2] [b3] [R]
x20 x20 x20 x20 x20 x20 x20
After battles, a3 and R units got damaged and order presented like,
[a1] [a2] [a3] [a3d1] [a3d4]
x20 x20 x18 x1 x1
[b1] [b2] [b3] [ R ] [ R ] [ R ]
x20 x20 x20 x16 x1d2 x1d3
-- d letter with number denotes total damaged red bar of the unit. As you can see, rogues listed 2 units less since 2 units lost in battle, whereas a3 has all 20 units after battles but 2 got damaged.
Now, our logic to move the damaged unit to last slot. Like I mentioned with letter 'd', each unit should be now keep a damage flag as a reference. When units get damaged, damage flag set to 'true'. Main step, when grouping or sorting triggers, units whichever consists of damage flag set to true will not be considered and there current index position will be recorded and once all other non damage units finsihed, these damaged units pushed into last slots with index position which has lower gets displayed first since it is highest age unit.
Here attached and unattached doesn't get compromise to stay in same house/slot, that's need an explanation from Dev's which raised earlier itself. According to me, stacked unit logic is very simple, but moving damaged unit is not a simple one. Without the actual code, gave my perception on how things will get impact. It would be better, if Dev's share any comments to CMs or Mods regarding it.