【发布时间】:2010-11-29 10:45:48
【问题描述】:
似乎我错过了一些微不足道的东西。
不管怎样,就这样吧:
var order = new[]{1,3,2};
var foos = new[]{new Foo{Id=1}, new Foo{Id=2}, new Foo{Id=3}};
如何使用 Linq 按顺序数组对 foos 进行排序?
想要的结果:
foos == new[]{new Foo{Id=1}, new Foo{Id=3}, new Foo{Id=2}};
编辑:
订单包含 Foo id。对不起,我没有提到这一点。有时,正确地提问比回答问题更难。 :)
【问题讨论】:
-
order数组是否指定了数组索引或Ids 的Foos? -
确实 - 请澄清问题。我已经在我的回答中解释了我认为您所要求的内容,但我只是在猜测。 (例如,Dale Halliwell 猜到了不同的意思。)