linq 如何在C#中为泛型IList&lt;List &gt;使用Order By< object>?[关闭]

o2rvlv0m  于 9个月前  发布在  C#
关注(0)|答案(1)|浏览(112)

**已关闭。**此问题需要debugging details。目前不接受答案。

编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
4天前关闭。
Improve this question
我有一个泛型IList<List<object>>,我想按List中的第4个元素对其进行排序。如何实现?
我尝试了下面的代码,但是它不能在IList中对List进行排序,我不知道该怎么做。它不会给予任何错误,但是也不会对它进行排序。

var orderedList = myList.OrderBy(x => x.ElementAt(3));

字符串
在这种情况下,myListIList<List<object>>
sample data

s4n0splo

s4n0splo1#

列表提供了比IEnumerables更多的功能。您的代码当前正在创建一个IEnumerables。如果您想要列表的功能,您可以将您的输出变成这样的列表:

var orderedList = myList.OrderBy(x => x.ElementAt(3)).ToList();

字符串

相关问题