首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

List排序有关问题!

2012-06-15 
List排序问题!急!!!ListObjectInVedio temp3 new ListObjectInVedio()temp3.Sort(delegate(ObjectI

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();

热点排行