my XML tag contains many items that should be threated as three different groups, with similar (but different) sorting rules.
This is what I want to get:
<items>
<!-- Header - for-each sorting -->
<item name="something1_A"/>
<item name="something2_B"/>
<item name="something3_C"/>
<!-- Body - for-each-group sorting -->
<item name="something4_D"/>
<item name="something4_E"/>
<item name="something5_D"/>
<item name="something5_E"/>
<!-- Footer - for-each sorting -->
<item name="something6_F"/>
<item name="something6_G"/>
<item name="something6_H"/>
</items>
Initially, items order is random.
The first sort should create those three different parts: put everything that is header on the top, everything that is footer on the bottom, and keep everything else where it is. I can determine if something should go in the header, in the body or in the footer looking at its ending (the value after the last underscore).
The second sort should work differently on each of those parts (per-element sorting for header and footer, per-group sorting for body).
I know how I can sort the header, the body and the footer (thanks to this answer), but not how to move them and sort them with different algorithms.