相同地排序两个列表 [英] Identically sorting two lists

查看:28
本文介绍了相同地排序两个列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串列表和一个整数列表.它们成对出现,即在索引处,给定的字符串和整数仍必须匹配".我需要按降序对整数进行排序,并让字符串完全相同地排序,因此对对是完整的.我想最好的实现方式可能是将它们放到List>中,但是我不确定第二个Tuple项如何对它们进行排序.

I have on list of strings, and one list of integers. They come in "pairs", i.e. at an index, the given string and integer must still be "matched up". I need to sort the integers in descending order and have the strings sort identically, so the pairs are intact. I imagine the best way to achieve may be to just put them into List>, but I'm not sure how that could be sorted by the second Tuple item.

推荐答案

如果您有元组列表,则可以像这样订购它们

If you have a list of Tuples you could order them like this

myList.OrderBy(x => x.Item2);

这篇关于相同地排序两个列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆