NS字典排序问题
我有一个 NSDictionary 数组。
NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:bothUserName forKeys:bothUID]; // here array "bothUserName" and "bothUID" is an NSArray type
[dictionary keysSortedByValueUsingSelector:@selector(compare:)];
NSLog(@" dictionary objects %@",dictionary);
我得到这样的输出。
dictionary objects {
14172368 = webtickle;
271882407 = electrodealio;
314125883 = Coral5mz;
316212228 = ajaysinghHF2;
316348693 = Caroline99a;
43944597 = WorldStuffer;
}
但我想要这样的输出。
字典对象 {
316212228 = ajaysinghHF2;
316348693 = Caroline99a;
314125883 = Coral5mz;
271882407 = electrodealio;
14172368 = webtickle;
43944597 = WorldStuffer;
}
提前致谢。
I have an array of NSDictionary.
NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:bothUserName forKeys:bothUID]; // here array "bothUserName" and "bothUID" is an NSArray type
[dictionary keysSortedByValueUsingSelector:@selector(compare:)];
NSLog(@" dictionary objects %@",dictionary);
I am getting an output like this.
dictionary objects {
14172368 = webtickle;
271882407 = electrodealio;
314125883 = Coral5mz;
316212228 = ajaysinghHF2;
316348693 = Caroline99a;
43944597 = WorldStuffer;
}
but I want to have output like this.
dictionary objects {
316212228 = ajaysinghHF2;
316348693 = Caroline99a;
314125883 = Coral5mz;
271882407 = electrodealio;
14172368 = webtickle;
43944597 = WorldStuffer;
}
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
keysSortedByValueUsingSelector 返回一个包含字典键的排序数组,您必须使用此返回的数组来检索关联的对象:
keysSortedByValueUsingSelector returns a sorted array containing dictionary's keys, you have to use this returned array to retrieve the associated objects: