标签:
// // main.m // 字典排序 // // Created by syrcfwzx on 16/1/8. // Copyright (c) 2016年 syrcfwzx. All rights reserved. // #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { NSDictionary* dic1 = @{@"1-1":@"02", @"1-2":@"11", @"1-3":@"89", @"1-4":@"7",}; NSArray* array = [dic1 allValues]; //遍历 for(id str in array) { NSLog(@"%@",str); } //BLOCK排序 NSArray* array2=[array sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { int object1 = [obj1 intValue]; int object2 = [obj2 intValue]; if(object1>object2) { return NSOrderedDescending; } else if (object1==object2) { return NSOrderedSame; } else { return NSOrderedAscending; } }]; NSLog(@"%@",array2); } return 0; }
标签:
原文地址:http://www.cnblogs.com/hezhuangzhuang/p/5114040.html