zoukankan      html  css  js  c++  java
  • List的Sort自定义排序实例

    List<UnRecruitInfo> recreuitList = dic["招聘会"] as List<UnRecruitInfo>;
                    //需要对招聘会的列表重新排序
                    //排序规则:召开时间>=今天的,进行顺排(从今天到将来),其他的顺序不变(从今天到过去,即过期的)
                    DateTime now = DateTime.Parse(DateTime.Now.ToShortDateString()),
                             aTime,
                             bTime;
                    recreuitList.Sort(delegate(UnRecruitInfo a, UnRecruitInfo b)
                    {//排序开始
                        aTime = DateTime.Parse(a.RecTime.ToShortDateString());
                        bTime = DateTime.Parse(b.RecTime.ToShortDateString());
                        if (a.RecTime >= now && b.RecTime >= now)
                        {//顺排(从小到大)

                            if (aTime < bTime) return -1;
                            else if (aTime > bTime) return 1;
                            else return 0;
                        }
                        else
                        {//倒排(从大到小)
                            if (aTime < bTime) return 1;
                            else if (aTime > bTime) return -1;
                            else return 0;
                        }
                    });
                    rptZQZP.DataSource = recreuitList;
                    rptZQZP.DataBind();

  • 相关阅读:
    log4j2 标签解析
    7.3
    work-7.2
    爬取豆瓣上某个用户标记的想读的或者读过的图书信息
    python爬虫程序打包为exe程序并在控制台下运行
    爬取任意两个用户在豆瓣上标记的想读的图书信息的交集
    解决c# progressBar更新出现界面假死
    数据库死锁(大神请路过)
    Excel的下载和读取,部分代码(大神请路过)
    大数据缓存:redis
  • 原文地址:https://www.cnblogs.com/Denny_Yang/p/2054070.html
Copyright © 2011-2022 走看看