I am trying to sort an XML document by element using LINQ. The XML is the following.
<Person>
<aaaInformation>
<lastName>Johnson</lastName>
<firstName>Zion</firstName>
<birthInfo>
<town>Los Angeles</town>
<hospital>LA Hospital</hospital>
</birthInfo>
</aaaInformation>
<Gender>Male</Gender>
</Person>
What I would like it to look like is below. (i.e. aaaInformation and Gender were left in the same position, birthInfo was moved to the top since it comes alphabetically before firstName/lastName, and lastName was moved to the bottom. Town and Hospital are also flipped.
<Person>
<aaaInformation>
<birthInfo>
<hospital>LA Hospital</hospital>
<town>Los Angeles</town>
</birthInfo>
<firstName>Zion</firstName>
<lastName>Johnson</lastName>
</aaaInformation>
<Gender>Male</Gender>
</Person>
Is there an easy way to do this? Additionally, these elements are just a small sample of a larger document with significantly more distinct elements, and thus I will not know ahead of time what the names of these elements are.