zoukankan      html  css  js  c++  java
  • 字典按中文姓名排序

    #define NSLog(FORMAT, ...) printf("%s ", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String])

    #import <Foundation/Foundation.h>

    int main(int argc, const char * argv[]) {

        @autoreleasepool {

            NSArray *aa=@[@{@"name":@"陈丰",@"age":@"32"},

                          @{@"name":@"孙明",@"age":@"24"},

                          @{@"name":@"王明",@"age":@"12"},

                          @{@"name":@"李西",@"age":@"50"}

                          ];

            NSMutableArray *aa1=[[NSMutableArray alloc]initWithArray:aa];

            NSSortDescriptor *bb=[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:1 selector:@selector(localizedCompare:)];

            NSArray *bb1=[aa1 sortedArrayUsingDescriptors:[NSArray arrayWithObjects:bb, nil]];

            for(int i=0;i<[bb1 count];i++)

            {

                NSDictionary *bb2=bb1[i];

                NSLog(@"名字:%@ 年龄:%@",bb2[@"name"],bb2[@"age"]);

            

            }

        }

        return 0;

    }

  • 相关阅读:
    触屏时间控制
    小程序 坐标算距离 (copy)
    微信小程序 对接口常用
    conversion function to_char to_number
    南通
    日期 function
    数字 function
    字符串处理函数
    沪通铁路1
    NVL NVL2 COALESCE NULLIF decode
  • 原文地址:https://www.cnblogs.com/bobohahaha/p/5120831.html
Copyright © 2011-2022 走看看