iPhone Obj C -- 对可变字典数组进行排序 -- 显示字符串但按值排序
我有一个 NSMutableArray,里面有 30 个字典。每个都包含一个名称和一个值。我目前已对名称进行排序,以便按字母顺序显示在表格视图中。但是,我想制作一个 UIButton 来提供仍然显示名称的选项,但按值排序。该值不需要显示。另外,这些代码将放置在 .m/.h 文件中的什么位置?谢谢!
I have a NSMutableArray with 30 dictionaries inside of it. Each contains a name and a value. I currently have the names sorted so that the show in a table view alphabetically. However, I'd like to make a UIButton to give the option of STILL DISPLAYING THE NAMES, but ordered by the value. The value doesn't need to be displayed. Also, where in the .m/.h files would these codes be placed? THANKS!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了能够帮助您,我需要一个测试数据来使用。假设您的数据数组如下所示:
在这种情况下,这是按值对其进行排序的方法:
至于放置此代码的位置,请将其放置在需要重新排序的位置(当然在实现 [.m] 文件中) 。
HTH,如果有任何问题,请在评论中询问。
To be able to help you I need a test data to work with. Let's say your array with data looks like this:
In this case case here's how you sort it by value:
As for where to place this code place it wherever you need the reordering to happen (in the implementation [.m] file of course).
HTH and if there will be any questions ask them in the comments.