我有这门课:
public class Leg
{
public int Day { get; set; }
public int Hour { get; set; }
public int Min { get; set; }
}
我有一个获取腿列表的函数,称为 GetLegs()
List<Leg> legs = GetLegs();
现在我想对这个列表进行排序。所以我必须首先考虑日期,然后是小时,最后是分钟。 这个排序应该怎么解决?
谢谢
最佳答案
也许是这样的:
List<Leg> legs = GetLegs()
.OrderBy(o=>o.Day)
.ThenBy(o=>o.Hour)
.ThenBy(o=>o.Min).ToList();
关于c# - 按属性对对象列表进行排序 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9716273/