iOS字母排序、数字排序
2014-02-21 17:09
302 查看
NSMutableArray *_array = [[NSMutableArray
alloc] initWithObjects:@"4",
@"1", @"10",
@"2", nil];
_array = [[NSMutableArray
alloc] initWithArray:[_array
sortedArrayUsingComparator:^NSComparisonResult(id obj1,
id obj2) {
// return [obj1 compare:obj2 options:NSNumericSearch]; //a按照首位排序
return [obj1
compare:obj2 options:NSForcedOrderingSearch];
}]];
_array = [[NSMutableArray
alloc] initWithArray:[_array
sortedArrayUsingSelector:@selector(compare:)]];
//
NSMutableArray *_allKeys = [[NSMutableArray
alloc]initWithArray:[self.dataDic
allKeys]];
//升序排序
_allKeys = [[NSMutableArray
alloc]initWithArray:[_allKeys
sortedArrayUsingSelector:@selector(compare:)]];
_allKeys = [[NSMutableArray
alloc]initWithArray:[_allKeys
sortedArrayUsingComparator:^NSComparisonResult(id obj1,
id obj2) {
return [obj1
compare:obj2 options:NSNumericSearch] ==
NSOrderedDescending;
}]];
NSLog(@"_allKeys%@",_allKeys);
参考文章:http://blog.csdn.net/tetrisos/article/details/7671282 http://hi.baidu.com/ivan_xu/item/5d897c14d51bffe0ddeeca7c http://code4app.com/snippets/one/排序/521dc6836803fad866000000
alloc] initWithObjects:@"4",
@"1", @"10",
@"2", nil];
_array = [[NSMutableArray
alloc] initWithArray:[_array
sortedArrayUsingComparator:^NSComparisonResult(id obj1,
id obj2) {
// return [obj1 compare:obj2 options:NSNumericSearch]; //a按照首位排序
return [obj1
compare:obj2 options:NSForcedOrderingSearch];
}]];
_array = [[NSMutableArray
alloc] initWithArray:[_array
sortedArrayUsingSelector:@selector(compare:)]];
//
NSMutableArray *_allKeys = [[NSMutableArray
alloc]initWithArray:[self.dataDic
allKeys]];
//升序排序
_allKeys = [[NSMutableArray
alloc]initWithArray:[_allKeys
sortedArrayUsingSelector:@selector(compare:)]];
_allKeys = [[NSMutableArray
alloc]initWithArray:[_allKeys
sortedArrayUsingComparator:^NSComparisonResult(id obj1,
id obj2) {
return [obj1
compare:obj2 options:NSNumericSearch] ==
NSOrderedDescending;
}]];
NSLog(@"_allKeys%@",_allKeys);
参考文章:http://blog.csdn.net/tetrisos/article/details/7671282 http://hi.baidu.com/ivan_xu/item/5d897c14d51bffe0ddeeca7c http://code4app.com/snippets/one/排序/521dc6836803fad866000000
相关文章推荐
- IOS7 IOS5 IOS6 内容覆盖住的问题 解决方法
- IOS Table中Cell的重用reuse机制分析
- 关于ios分享(ShareSDK)
- [iphone]Code Sign error: Provisioning profile XXXX can't be found
- iOS中获取相册中图片的文件名
- ios删除文件代码
- 对iOS中序列化的一些理解(写入文件)
- 一步一步教你做ios推送
- IOS7适配 总结
- IOS自动化打包
- IOS 消息机制(NSNotificationCenter)
- IOS开发缓存机制之—内存缓存机制
- IOS开发缓存机制之—本地缓存机制
- Minimum Cost poj 2516 最小费用最大流,贵在建图+模板
- 新闻客户端首页图片无限循环滚动展示(可点击触发不同事件)初步封装IOS
- IOS Xmpp的Iq发送和解析之请求讨论组成员
- iOS多线程编程Part 2/3 - NSOperation
- iOS多线程编程Part 1/3 - NSThread & Run Loop
- iOS多线程编程Part 3/3 - GCD
- IOS中的几种锁(转)