我搜索了如何对列表中的列表进行排序'的课程。在我atractions[i].profit
我的利润上,我想对那份清单进行排序。下面我展示我的代码并尝试解析它。
class AtractionPoint
{
public double coordinateX { set; get; }
public double coordinateY { set; get; }
public double stylePoints { set; get; }
public List<int> distances = new List<int>();
public List<double> profit = new List<double>();
public List<double> neighbour = new List<double>();
public AtractionPoint(double x, double y, double s)
{
coordinateX = x;
coordinateY = y;
stylePoints = s;
}
}
for (int i = 0; i < atractionsCount; i++)
{
for (int j = 0; j < atractionsCount; j++)
{
if (i == j)
atractions[i].profit.Add(0);
else
atractions[i].profit.Add(atractions[i].stylePoints / atractions[i].distances[j]);
}
atractions[i].profit.OrderBy(d => atractions[i].profit);
}