两个列表,一个按升序排序,另一个按降序排序但受约束
有一个非常基本的问题: 我需要在 C# 中实现这个。 我有两个列表说 List1 和 List2
List1 23,34,45,12,34,34,67,100,34
List2 0.1,0.3,0.1,0.2,0.15,0.17,0.91,0.81,0.3
正如你所看到的有重复list1 中的数据点数量(本例中为 34 个) 我必须按 List2 上约束的降序对 List1 进行排序,这样如果 List1(34) 中有重复的条目,则从 List2 中获取最高的对应值(这里 34 有 0.3,0.3,0.17 和 0.15) 所以输出应该是第一个对应于0.3的34,然后是0.3,然后是0.17,然后是0.15
List1 100,67,45,34,34,34,34,23,12
List2 0.81,0.91,0.1,0.3,0.3,0.17 ,0.15,0.1,0.2
Got very basic question:
I need to implement this in C#.
I have got two list Say List1 and List2
List1 23,34,45,12,34,34,67,100,34
List2 0.1,0.3,0.1,0.2,0.15,0.17,0.91,0.81,0.3
As you can see there is duplication of data points in list1 (34 in this case)
I have to sort List1 in descending order constrained on List2 such that if there is duplicated entry in List1(34) then take the highest corresponding value from List2 (here 34 has got 0.3,0.3,0.17 and 0.15)
So output should be first 34 corresponding to 0.3, then to 0.3 then to 0.17 and then to 0.15
List1 100,67,45,34,34,34,34,23,12
List2 0.81,0.91,0.1,0.3,0.3,0.17,0.15,0.1,0.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来像:
结果将是一个匿名类型的序列,其中
x
对应于list1
中的值,y
对应于list2
,整个内容按x
降序排列,然后是y
。That looks like:
The result will be a sequence of an anonymous type where
x
corresponds to a value inlist1
,y
corresponds to a value inlist2
, and the whole thing is sorted in a descending order onx
theny
.