0
개체 목록을 정렬하기위한 기존 코드 비트가 있습니다. 일반 컬렉션 정렬을 사용하여 Linq 활용
productsList.Sort(
delegate(Product p1, Product p2)
{
int result = p1.StartDatetime.CompareTo(p2.StartDatetime);
if (result == 0)
{
if (p1.SomeId == p2.SomeId)
{
result = 0;
}
else if (p1.SomeId == null)
{
result = -1;
}
else if (p2.SomeId == null)
{
result = 1;
}
}
return result;
});
나는이가로 교체하여 간단하게 할 수 있다는 느낌이 :
productsList = productsList
.OrderBy(p => p.StartDatetime)
.ThenBy(p => p.SomeId)
.ToList();
내 가정에서 수정 건가요?