Sort an array and return index of arrays according to elements size in c#

后端 未结 2 1168
长发绾君心
长发绾君心 2021-01-26 21:00

I need to sort the array from minimum to maximum value, but I need to return only the index of array after sorting it. I dont want to swap values, I just need to return the valu

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-26 21:24

    var indexes = arr.Select((i, inx) => new { i, inx })
                      .OrderBy(x => x.i)
                      .Select(x => x.inx)
                      .ToArray();
    

提交回复
热议问题