字典 排序

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
//字典排序
        NSDictionary *dic=@{@"1-1":@"02",
                            @"1-2":@"11",
                            @"1-3":@"98",
                            @"1-4":@"7"};
        NSArray *arr=[dic allValues];
        for (id str in arr) {
            NSLog(@"%@",str);
        }
        arr=[arr sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
            return [obj1 compare:obj2];
        }];
        NSLog(@"排序后");
        for (id str in arr) {
            NSLog(@"%@",str);
        }
        
        
        
    }
    return 0;
}

 

posted @ 2016-01-11 13:04  纽伦堡幅度  阅读(130)  评论(0编辑  收藏  举报