public class ClippedRasterComparer : IComparer<ClippedRaster> { public int Compare(ClippedRaster clr1, ClippedRaster clr2) { //return clr1._absoluteVolume.CompareTo(clr2._absoluteVolume);//升序 return clr2._absoluteVolume.CompareTo(clr1._absoluteVolume);//降序 } }
//定义类ClippedRasterComparer,在类中实现排序接口。
ICompare<> 尖括号内的写用于排序的对象类型。可以写List<>的元素类型
//按_absoluteVolume升序排列 ClippedRasterComparer crp=new ClippedRasterComparer(); li_intersectedRasters.Sort(crp);