c# - LINQ OrderBy with more than one field -
I have a list that has been sorted by two fields. I tried to use OrderBy in LINQ but it only allows me to specify a field. I'm looking for sorting by list for the first field and then if there are duplicates in the first field to sort according to the second field I
For example, I want to look like this
I have seen that you can use it, but I can order it
IList Person> ListOfPeople = / * The copy is filled in some way. * / IEnumerable & lt; person & gt; SortedListOfPeople = listOfPeople.OrderBy (aPerson = & gt; aPerson.ListName, aPerson.FirstName); // This does not work
You need to use:
listOfPeople Order-B (person = & Gt; person.lostname) then (person => firstname)
Comments
Post a Comment