ApprovalUtilities.Xml.XmlUtils.SortAttributes C# (CSharp) Method

SortAttributes() public static method

public static SortAttributes ( System.Xml.Linq.XElement xElement ) : void
xElement System.Xml.Linq.XElement
return void
	    public static void SortAttributes(XElement xElement)
	    {
	        var orderedNodes = xElement.Attributes().OrderBy(e => e.ToString()).ToArray();
	        xElement.RemoveAttributes();
	        
            foreach (var attribute in orderedNodes)
	        {
	            xElement.SetAttributeValue(attribute.Name, attribute.Value);
	        }

	        foreach (var node in xElement.Nodes().Where(n => n is XElement))
	        {
	            SortAttributes((XElement)node);
	        }
	    }
	}