Sort/orderby nodes in xml using IComparer

williamroyal

New Member
I need to sort nodes in xml. I have the following code which successfully orders them alphabetically. However, much of the data is numeric although strings are allowed. I have a IComparer set up that works to correctly sort data as I wish it to appear elsewhere. \[code\]System.Xml.Linq.XDocument output = new System.Xml.Linq.XDocument( new System.Xml.Linq.XElement("xml", from node in input.Root.Elements("training") orderby node.Attribute("order").Value select node));\[/code\]I've found how to use an IComparer in a method call, \[code\].OrderBy(x => x, new CustomComparer())\[/code\] But, I haven't figured out how to get that to work with the xml. From what I've read online, it doesn't look like I can call an IComparer from the query syntax.
 
Back
Top