List<T> 排序

List<T>的排序

 

           List<DataPoint> dataPointsDataPints = 
...;
//按RegisterAddress升序排序 dataPointsDataPints.Sort(
new DataPointRegisterAddressCompare());


排序类:

    public class DataPointRegisterAddressCompare : IComparer<DataPoint>
    {
        public int Compare(DataPoint x, DataPoint y)
        {
            return x.StartRegisterAddress.CompareTo(y.StartRegisterAddress);
        }
    }

 

posted @ 2013-09-09 16:36  easy5  阅读(182)  评论(0编辑  收藏  举报