• 数组按时间(字符串->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);

            }

            

  • 相关阅读:
    BZOJ4553: [Tjoi2016&Heoi2016]序列
    BZOJ4552: [Tjoi2016&Heoi2016]排序
    BZOJ4551: [Tjoi2016&Heoi2016]树
    BZOJ4556: [Tjoi2016&Heoi2016]字符串
    BZOJ4546: codechef XRQRS
    CC 3-Palindromes(manacher)
    hdu3294(manacher)
    hdu4513(manacher)
    poj3974(manacher)
    CF 518D(概率dp)
  • 原文地址:https://www.cnblogs.com/Jenaral/p/5807441.html
Copyright © 2020-2023  润新知