【发布时间】:2019-09-25 12:36:54
【问题描述】:
我有一个清单:
List<Tuple<int, int>> MyList = new List<Tuple<int, int>>();
列表的值如下:
int int
0 2
0 1
0 4
1 2
1 3
1 0
2 0
2 9
2 1
3 2
3 5
3 2
如何按Item2 的最高 值对list 进行排序,但保存Item1 的顺序?如下:
int int
2 0
2 9*
2 1
3 2
3 5*
3 2
0 2
0 1
0 4*
1 2
1 3*
1 0
尝试使用MyList.OrderBy(x => x.Item2)但没有成功
【问题讨论】:
-
所需的排序顺序是什么?该示例不按 Item2 排序。除非你的意思是
find the max Item2 value per Item1 then order the tuples by theMax` 值?