zoukankan      html  css  js  c++  java
  • 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());//
  • 相关阅读:
    Java中String做为synchronized同步锁
    99%的人都理解错了GET与POST的区别
    为什么Java中只有值传递
    解决maven打包时,会编译特定文件导致文件不可用
    Java使用icepdf转高清图片
    iText输出中文
    Error:(1, 1) java: 非法字符: ‘ufeff’
    java根据模板生成pdf
    携程Apollo统一配置中心的搭建和使用
    1008
  • 原文地址:https://www.cnblogs.com/panjun/p/2237305.html
Copyright © 2011-2022 走看看