(Using the latest MVC 2 RC 2) I'm trying to sort some XML in LINQ (C#) by an element's attribute's value...
var sites = from s in xDoc.Element("sites").Elements("开发者_如何转开发site")
orderby s.Attribute("name")
select s;
But when I pass this to my View I get the exception:
Exception Details: System.ArgumentException: At least one object must implement IComparable.
Source Error: 
Line 37:                </th>
Line 38:            </tr>
Line 39:            <% foreach (var item in Model)
Line 40:               { %>
Line 41:            <tr>
Can someone tell me how to sort XML using LINQ and have it render properly?
EDIT: Okay, I think you just want:
var sites = from s in xDoc.Element("sites").Elements("site")
            orderby (string) s.Attribute("name")
            select s;
Which could also be written as:
var sites = xDoc.Element("sites")
                .Elements("site")
                .OrderBy(s => (string) s.Attribute("name"));
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论