字典 排序例题

#import <Foundation/Foundation.h>

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

    @autoreleasepool {

        NSDictionary *dic=@{@"1":@"02",

                            @"2":@"30",

                            @"3":@"11",

                            @"4":@"7"

                            };

        NSArray *arr=[dic allKeys];

        for ( id str in arr) {

            NSLog(@"%@",str);

        }

        arr=[arr sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {

            return  [obj1 compare:obj2];

        }];

        for(id str1 in arr){

            NSLog(@"%@",str1);}

    }

    return 0;

}

原文地址:https://www.cnblogs.com/j-h-t-123-n/p/5116225.html