字典排序

//

//  main.m

//  字典排序

//

//  Created by 博博 on 16/1/8.

//  Copyright (c) 2016年 com.bb. All rights reserved.

//

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

#import <Foundation/Foundation.h>

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

    @autoreleasepool {

        NSDictionary *dic=@{@"1-1":@"02",@"1-2":@"11",@"1-3":@"89",@"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];}];

        

        for(id str in arr){

            NSLog(@"%@",str);

        }

        

        

    }

    return 0;

}

原文地址:https://www.cnblogs.com/bobohahaha/p/5120936.html