美文网首页
iOS 开发 根据字典里某个值进行排序

iOS 开发 根据字典里某个值进行排序

作者: 从小就是菜鸟 | 来源:发表于2020-01-09 14:02 被阅读0次

NSArray *arr = @[@{@"amount":@"11090",@"date":@"2018-07-12 19:53:45",@"name":@"y"},

                     @{@"amount":@"1980",@"date":@"2019-07-12 19:53:45",@"name":@"d"},

                     @{@"amount":@"11087",@"date":@"2020-07-12 19:53:45",@"name":@"g"},

                     @{@"amount":@"11095",@"date":@"2020-07-18 19:53:45",@"name":@"c"},

                     @{@"amount":@"77",@"date":@"2018-07-12 19:53:46",@"name":@"a"}];

    NSArray *arrNmaeDesc = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];

    NSArray *arrDateDesc = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES]];

    NSArray *arrAmountDesc = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"amount" ascending:YES]];

    NSArray*arrNmae = [arrsortedArrayUsingDescriptors:arrNmaeDesc];

    NSArray*arrDate = [arrsortedArrayUsingDescriptors:arrDateDesc];

    NSArray*arrAmount = [arrsortedArrayUsingDescriptors:arrAmountDesc];

相关文章

网友评论

      本文标题:iOS 开发 根据字典里某个值进行排序

      本文链接:https://www.haomeiwen.com/subject/kayyactx.html