List排序问题!急!!!
List<ObjectInVedio> temp3 = new List<ObjectInVedio>();
temp3.Sort(delegate(ObjectInVedio v1, ObjectInVedio v2)
{
return v2.dist.CompareTo(v1.dist);
});
求解怎么从小到大 和从大到小排序
------解决方案--------------------
List<ObjectInVedio> temp3 = new List<ObjectInVedio>();
temp3.Sort(delegate(ObjectInVedio v1, ObjectInVedio v2)
{
return v2.dist.CompareTo(v1.dist);
});
List<ObjectInVedio> temp3 = new List<ObjectInVedio>();
temp3.Sort(delegate(ObjectInVedio v1, ObjectInVedio v2)
{
return v1.dist.CompareTo(v2.dist);
});
or
List<ObjectInVedio> temp3 = new List<ObjectInVedio>();
temp3 = temp3.OrderBy(x => x.dist).ToList();
temp3 = temp3.OrderByDescending(x => x.dist).ToList();