我的控制台输出是:
这是我的代码:
PosList.Add(cog);
PosList = PosList.OrderByDescending(p=>p.Y).ToList();
我无法对我的观点进行排序,能否请你帮我建立一个排序...
答案 0 :(得分:-1)
尝试以下操作:
List<Point> points = new List<Point>() {
new Point(388, 380),
new Point(388, 380),
new Point(220, 379),
new Point(388, 380),
new Point(220, 379),
new Point(53, 379),
new Point(388, 380),
new Point(220, 379),
new Point(53, 379),
new Point(53, 211),
new Point(388, 380),
new Point(220, 379),
new Point(53, 379),
new Point(53, 211),
new Point(391, 206),
new Point(388, 380),
new Point(220, 379),
new Point(53, 379),
new Point(53, 211),
new Point(220, 211),
new Point(391, 206),
new Point(388, 380),
new Point(220, 379),
new Point(53, 379),
new Point(53, 211),
new Point(220, 211),
new Point(391, 206),
new Point(220, 43),
new Point(388, 380),
new Point(220, 379),
new Point(53, 379),
new Point(53, 211),
new Point(220, 211),
new Point(391, 206),
new Point(220, 43),
new Point(52, 43),
new Point(388, 380),
new Point(220, 379),
new Point(53, 379),
new Point(53, 211),
new Point(220, 211),
new Point(391, 206),
new Point(220, 43),
new Point(52, 43),
new Point(389, 42)
};
List<List<Point>> sorted = points.OrderBy(x => x.Y).ThenBy(x => x.X).GroupBy(x => x.Y).Select(x => x.ToList()).ToList();