どう見てもC#じゃないワンライナー
可読性(笑)みたいな。
var output = new XElement( "Plants", doc.Root.Elements().GroupBy( plant => plant.Element( "Belong" ).Value, plant => int.Parse( plant.Element( "Power" ).Value ) ).OrderByDescending( group => group.Average() ).Select( group => new XElement( "Plant", new XElement( "Belong", group.Key, new XAttribute( "PlantCounts", group.Count().ToString() ) ), new XElement( "Power", group.Average().ToString() ) ) ) );