How Do I Sort IList?

后端 未结 6 1262
终归单人心
终归单人心 2021-01-11 23:14

There\'s no Sort() function for IList. Can someoene help me with this? I want to sort my own IList.

Suppose this is my IList:



        
6条回答
  •  清酒与你
    2021-01-12 00:02

    OrderBy definitely gets the job done, but I personally prefer the syntax of List.Sort because you can feed it a Comparison delegate instead of having to write a class that implements IComparer. We can accomplish that goal with an extension method, and if that's something you're interested in, check out SortExtensions:

    http://blog.velir.com/index.php/2011/02/17/ilistt-sorting-a-better-way/

提交回复
热议问题