Making it happen
Linq Select Indices of Top Ordered Elements
I’ve recently got over the second Select variant, so now I can do the following to find the top 3 elements:
double[] output = new double[] { 5,6,7,8,9 };
var indices = output.Select( (v,i) => new { v = v, i = i}).OrderByDescending( p => p.v).Take(3).Select( p => p.i);
| Print article | This entry was posted by andrei on February 24, 2010 at 1:13 pm, and is filed under Uncategorized. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
