开发者社区 问答 正文

根据关键字的价格排序

关键字排序问题:

每个dictionary对象有不同的数据类型,全部dictionary都当做string提取了,怎么样将这些string类型的数据转换为不同类型,然后根据价格排序。

-(IBAction)PriceSort:(id)sender
{
    NSSortDescriptor * sort = [[NSSortDescriptor alloc] initWithKey:@"Price" ascending:true] ;
    NSArray *sa = [symbolArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
    NSLog(@"price=%@",sa);

}

输出:

{

    volume = 2496752;

    Yield = "10.49";

    MarCap = 829;

    Price = "0.715";

    Symbol = SAIPI;

}

展开
收起
爵霸 2016-03-24 10:12:42 1953 分享 版权
1 条回答
写回答
取消 提交回答
  • sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"price"
                                                     ascending:YES selector:@selector(localizedStandardCompare:)] ;
    2019-07-17 19:12:04
    赞同 展开评论
问答地址: