The easiest way is to put them into a single List
, and then order that list:
List<string> list = new List<string>() { "A", "C", "T", "F" };
List<int> list2 = new List<int>() { 5, 4, 3, 2 };
var results = list.Zip(list2, (a, b) => new
{
str = a,
num = b
})
.OrderBy(pair=> pair.num);
If you really need a list of just the strings you could use a Select
to get them back out, but hopefully it just makes sense to have a single list of a more complex object throughout your program. (Consider making an actual class, rather than using an anonymous one, if you do that.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…