码迷,mamicode.com
首页 > 编程语言 > 详细

数组套字典排序

时间:2015-12-09 19:16:39      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

 1 {
 2     "status": "1",
 3     "msg": "\u6210\u529f",
 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 }

 

数组套字典排序

标签:

原文地址:http://www.cnblogs.com/-yun/p/5033301.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!