zoukankan      html  css  js  c++  java
  • 数组按时间(字符串->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);

            }

            

  • 相关阅读:
    JavaScript操作符instanceof揭秘
    Linux打开txt文件乱码的解决方法
    Working copy locked run svn cleanup not work
    poj 2299 UltraQuickSort 归并排序求解逆序对
    poj 2312 Battle City 优先队列+bfs 或 记忆化广搜
    poj2352 stars 树状数组
    poj 2286 The Rotation Game 迭代加深
    hdu 1800 Flying to the Mars
    poj 3038 Children of the Candy Corn bfs dfs
    hdu 1983 Kaitou Kid The Phantom Thief (2) DFS + BFS
  • 原文地址:https://www.cnblogs.com/Jenaral/p/5807441.html
Copyright © 2011-2022 走看看