zoukankan      html  css  js  c++  java
  • 数组套字典排序

     1 {
     2     "status": "1",
     3     "msg": "u6210u529f",
     4     "data": {
     5         "detail_data": [{
     6             "stock_code": "430074",
     7             "now_price": 14.07,
     8             "increase": "1.3%",
     9             "open": 13.89,
    10             "general_capital": "108750000",
    11             "close": 14.07,
    12             "high": 14.14,
    13             "low": 13.89,
    14             "date": "2015-11-25",
    15             "vol": 723500,
    16             "amount": 10169420
    17         }, {
    18             "stock_code": "430074",
    19             "now_price": 13.93,
    20             "increase": "5.29%",
    21             "open": 13.23,
    22             "general_capital": "108750000",
    23             "close": 13.93,
    24             "high": 14.21,
    25             "low": 13.21,
    26             "date": "2015-11-23",
    27             "vol": 513000,
    28             "amount": 7116860
    29         }, {
    30             "stock_code": "430074",
    31             "now_price": 13.85,
    32             "increase": "-0.93%",
    33             "open": 13.98,
    34             "general_capital": "108750000",
    35             "close": 13.85,
    36             "high": 14.3,
    37             "low": 13.5,
    38             "date": "2015-11-24",
    39             "vol": 538000,
    40             "amount": 7546040
    41         }],
    42         "date_data": ["2015-11-04", "2015-11-05", "2015-11-06", "2015-11-09", "2015-11-10", "2015-11-11", "2015-11-12", "2015-11-13", "2015-11-16", "2015-11-17", "2015-11-18", "2015-11-19", "2015-11-20", "2015-11-23", "2015-11-24", "2015-11-25", "2015-11-26", "2015-11-27", "2015-11-30", "2015-12-01", "2015-12-02", "2015-12-03"]
    43     }
    44 }

    ^^^^^^数据源

    方法下面

     1 -(void) setDatas{
     2     NSMutableArray *detailArray = [NSMutableArray arrayWithArray:[[all_Dic objectForKey:@"data"] objectForKey:@"detail_data"]];
     3     NSLog(@"detailArray=%@",detailArray);
     4 
     5     NSSortDescriptor*sorter=[[NSSortDescriptor alloc]initWithKey:@"date" ascending:YES];
     6     NSMutableArray *sortDescriptors=[[NSMutableArray alloc]initWithObjects:&sorter count:1];
     7     NSArray *sortArray=[detailArray sortedArrayUsingDescriptors:sortDescriptors];
     8     NSLog(@"sortArray==%@",sortArray);
     9 
    10     
    11 }
    让明天,不后悔今天的所作所为
  • 相关阅读:
    PyQt5--基础篇:用eric6工具实现三级联动效果
    Django--基本篇:项目结构与设计模式(MVC)
    python文件最基础的读写删除
    Begin using git (Part1)
    Begin using git
    通用刷新数据源代码
    Combox程序中自定义数据源
    表内父子关系的递归查询
    C++ 获取数组长度
    Linux在终端里面切换root用户
  • 原文地址:https://www.cnblogs.com/-yun/p/5033301.html
Copyright © 2011-2022 走看看