Sort list of string arrays c#

前端 未结 4 1301
野的像风
野的像风 2021-01-18 02:11

I have a list of string arrays, where the arrays are formatted as [Animal, Breed, Name]:

{ [\"Dog\", \"Golden Retriever\", \"Rex\"],
  [\"Cat\", \"Tabby\", \         


        
4条回答
  •  [愿得一人]
    2021-01-18 02:28

    If you can use LINQ, you can do something like:

    myanimals = myanimals.OrderBy(a => a[0]).ThenBy(a => a[1]).ToList();
    

    Or the same in query:

    myanimals = (from a in animals order by a[0], a[1] select a).ToList();
    

提交回复
热议问题