• 数组按时间(字符串->Date)排序


    不说了 ,直接上代码。Talk is cheap , show me the code.

     

     

            NSArray *stortedArray = [wkSelf.dataArray sortedArrayUsingComparator:^NSComparisonResult(NSDictionary *_Nonnull obj1, NSDictionary *_Nonnull obj2) {

                NSLog(@"dateFromStringMore  one%ld",[[PublicMethod dateFromStringMore:((XRArticleModel *)obj1).article.createTime] compare:[PublicMethod dateFromString:((XRArticleModel *)obj2).article.createTime]]);

                

                NSLog(@"dateFromStringMore  twow%ld",[[PublicMethod dateFromString:((XRArticleModel *)obj2).article.createTime] compare:[PublicMethod dateFromStringMore:((XRArticleModel *)obj1).article.createTime]]);

                

                return [[PublicMethod dateFromStringMore:((XRArticleModel *)obj2).article.createTime] compare:  [PublicMethod dateFromString:((XRArticleModel *)obj1).article.createTime]];

            }];

     

            

             NSArray *shitfucker   = [wkSelf.dataArray sortedArrayUsingComparator:^NSComparisonResult(XRArticleModel *obj1, XRArticleModel *obj2) {

                 NSLog(@"shitfuckerOne = %ld",[[PublicMethod dateFromStringMore:obj2.article.createTime] compare:[PublicMethod dateFromStringMore:obj1.article.createTime ]]);

                 NSLog(@"shitfuckerTwo = %ld",[[PublicMethod dateFromStringMore:obj1.article.createTime ] compare:[PublicMethod dateFromStringMore:obj2.article.createTime]]);

                 return [[PublicMethod dateFromStringMore:obj2.article.createTime] compare:[PublicMethod dateFromStringMore:obj1.article.createTime ]];

            }];

            

            for (XRArticleModel *model in shitfucker) {

                NSLog(@"shitfuckerOhYes =%@",model.article.createTime);

            }

            

            for (XRArticleModel *model in stortedArray) {

                NSLog(@"stortedArray = %@",model.article.createTime);

            }

            

  • 相关阅读:
    redis持久化之AOF和RDB
    pycharm快捷键
    500系列错误
    400系列错误
    Linux常用命令大全
    从浏览器输入一个地址,发送请求,经历了哪些过程(面试问题)
    401的错误分析
    301和302的区别
    数据库 语法收集 (主 mysql,次oracle,日常积累)
    python 发送邮件 smtplib.SMTPAuthenticationError: (535, b'Error: authentication failed') 以及授权码设置步骤
  • 原文地址:https://www.cnblogs.com/Jenaral/p/5807441.html
Copyright © 2020-2023  润新知