In my application I have a list of items I need to sort by price and set a rank/position index for each item. I need to store the rank because the price may change afterward. At the moment I am doing it like this:
var sortedlistKFZ = from res in listKFZ orderby res.Price select res; if (sortedlistKFZ.Any()) { int rankPosition = 1; foreach (Result kfz in sortedlistKFZ) { kfz.MesaAdvertNumber = rankPosition; rankPosition++; } } Is there a shorter way to do it?