C# LINQ return counter array indices max to min -
a newbie c# , linq. have array counted sequence.
{1,3,5,2,7,2}
i trying write query returns list of indices highest values in descending order:
4,2,1,3,5,0
i can maximum index query below, can't seem work out how next indexes in sequence single query.
int index = array.tolist().indexof(array.max());
this works:
var list = new [] {1,3,5,2,7,2}; var indices = list .select((n, i) => new { n, }) .orderbydescending(x => x.n) .select(x => x.i) .toarray();
Comments
Post a Comment