<p>I want to change the order of XML using XDocument</p>

<pre><code>&lt;root&gt;
  &lt;one&gt;1&lt;/one&gt;
  &lt;two&gt;2&lt;/two&gt;
&lt;/root&gt;
</code></pre>

<p>I want to change the order so that 2 appears before 1.  Is this capability baked in or do I have to do it myself.  For example, remove  then AddBeforeSelf()?</p>

<p>Thanks</p>

This should do the trick. It order the child nodes of the root based on their content and then changes their order in the document. This is likely not the most effective way but judging by your tags you wanted to see it with LINQ.
```
```
static void Main(string[] args)
{
    XDocument doc = new XDocument(
        new XElement("root",
            new XElement("one", 1),
            new XElement("two", 2)
            ));

    var results = from XElement el in doc.Element("root").Descendants()
                  orderby el.Value descending
                  select el;

    foreach (var item in results)
        Console.WriteLine(item);

    doc.Root.ReplaceAll( results.ToArray());

    Console.WriteLine(doc);

    Console.ReadKey();
}
```
```