IComparer 指定排序。

    public class NeEntityComparer : IComparer<NeEntity>
    {
        public int Compare(NeEntity x, NeEntity y)
        {
            if (x == null)
            {
                if (y == null)
                {
                    // If x is null and y is null, they're

                    // equal. 

                    return 0;
                }
                else
                {
                    // If x is null and y is not null, y

                    // is greater. 

                    return -1;
                }
            }
            else
            {
                // If x is not null...

                //

                if (y == null)
                // ...and y is null, x is greater.
                {
                    return 1;
                }
                else
                {
                    // ...and y is not null, compare the 

                    // lengths of the two strings.

                    //



                    int retval = x.NeID.CompareTo(y.NeID);

                    return retval;
                }
            }


        }
    }

原文地址:https://www.cnblogs.com/m7777/p/4039334.html