Myt*_*ics 5 .net c# sorting list
在C#中:
List<List<Point>> SectionList = new List<List<Point>>();
Run Code Online (Sandbox Code Playgroud)
SectionList包含每个子列表在其包含的点数不同的点的列表.
我想弄清楚的是如何按子列表的计数按降序对SectionList进行排序.
因此,如果SectionList有3个点列表,则在排序后,SectionList [0]将包含所有3个列表的最高Count值.
谢谢,神话
das*_*ght 11
这应该工作:
SectionList.Sort((a,b) => a.Count - b.Count);
Run Code Online (Sandbox Code Playgroud)
这(a,b) => a.Count - b.Count是一个比较代表.该Sort方法与对列表进行比较的话来说,如果返回一个负数委托a短于b如果一个正数a长于b和零当两个列表是相同的长度.
var sortedList = SectionList.OrderByDescending(l=>l.Count()).ToList();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4287 次 |
| 最近记录: |