views:

729

answers:

2

How do I add a second item to order by with this? I want to order by a goalsScored element too.

var theteams = 
    (from teams in xdoc.Descendants("team")
     orderby (int)teams.Element("points") descending                               
     select 
         new Team(teams.Element("teamID").Value, 
                  (int)teams.Element("points"))                                
      ).Take(3);

but thenby doesn't seem to slot in to this query.

+5  A: 
var theteams =     
    (from teams in xdoc.Descendants("team")
    orderby (int)teams.Element("points") descending, OtherField1, OtherField2
    select new Team(teams.Element("teamID").Value,
    (int)teams.Element("points"))).Take(3);
tsilb
Ahh the trusty comma.
John Nolan
+3  A: 

You add multiple order clauses by separating them with commas, e.g.

orderby (int)teams.Element("points") descending, goalsScored
Brian Rasmussen