• List排序


        List<Person> list = new List<Person>();
                for (int i = 0; i < 50; i++)
                {
                    Person p = new Person();
                    p.Name = i.ToString() + "PersonName";      
                    p.ID = array[i];
                    list.Add(p);
                }

     list.Sort(new PersonComparer());


      public class Person
        {
            public string Name
            { getset; }

            public int ID
            { getset; }
        }
        public class PersonComparer : IComparer<Person>
        {
            public int Compare(Person x, Person y)
            {
                return x.ID.CompareTo(y.ID);
            }
        }
    private List<int> listRowspan = new List<int>();//用于保存所有标题列的跨行数

        /// <summary>
        
    /// 跨行数排序类
        
    /// </summary>
        class SortRowspan : IComparer<int>
        {

            public int Compare(int x, int y)
            {
                if (x > y)
                {
                    return 1;
                }
                else if (x < y)
                {
                    return -1;
                }
                else
                {
                    return 0;
                }
            }
        }


    listRowspan.Sort(new SortRowspan());//
  • 相关阅读:
    30、Java中Set集合之HashSet、TreeSet和EnumSet
    此地址使用了一个通常用于网络浏览以外的端口。出于安全原因,Firefox 取消了该请求。
    C# 关闭显示器(显示)
    29、java中阻塞队列
    28、队列和栈
    27、ArrayList和LinkedList的区别
    26、线性表(List)
    WMI使用的WIN32_类库名
    android 怎样加速./mk snod打包
    hdu1081 最大子矩阵
  • 原文地址:https://www.cnblogs.com/panjun/p/2237305.html
Copyright © 2020-2023  润新知