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

  • Smith, Peter
  • Thompson, Fred
  • 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

    Popular posts from this blog

    windows - Heroku throws SQLITE3 Read only exception -

    lex - Building a lexical Analyzer in Java -

    python - rename keys in a dictionary -