I am trying to transform an input XML where all parent nodes say \'x\' need to be extracted, sorted and then reordered in the final output XML based on their subnode say \'