Here is my current code that gets the elements from the xml and puts it into an array. But it just puts it in the order it reads it (top to bottom)
using System.Xml;
using System.Xml.Linq;
// XML Path
var doc = XDocument.Load("C:/Scripts/example.xml");
// Node
string[] picks = doc.Descendants("pick").Select(element => element.Value).ToArray();
I want to know if it is possible to sort the array by an attribute (in this case, "order") as I turn it into an array. The desired output being {Gragas, Draven, Ryze, Shen, Shyvanna, ...}
here's my xml:
<championSelect>
<blue>
<pick order="1">Gragas</pick>
<pick order="4">Shen</pick>
<pick order="5">Shyvanna</pick>
<pick order="8">Garen</pick>
<pick order="9">Karthus</pick>
</blue>
<red>
<pick order="2">Draven</pick>
<pick order="3">Ryze</pick>
<pick order="6">Ahri</pick>
<pick order="7">Annie</pick>
<pick order="10">Brand</pick>
</red>
I was playing with OrderBy() and OrderByDescending() with little luck