使用 sortUsingDescriptors 对日期字符串进行排序?
我有许多字典数组,
points = 200;
startDate = "Jun 04, 2011, 13:15 PM";
points = 200;
startDate = "May 01, 2011, 11:15 PM";
and -------
我必须根据开始日期进行排序。
我之前通过此方法使用过排序数量,例如数字排序等:
-(NSMutableArray*)SortEventsArray:(NSMutableArray*)arrayToSort :(NSString*)sortExpression
{
NSSortDescriptor *mySorter = [[NSSortDescriptor alloc] initWithKey:sortExpression ascending:YES];
[arrayToSort sortUsingDescriptors:[NSMutableArray arrayWithObject:mySorter]];
return arrayToSort;
}
但它不适用于日期字符串。
请帮忙
I have number of arrays of dictionary
points = 200;
startDate = "Jun 04, 2011, 13:15 PM";
points = 200;
startDate = "May 01, 2011, 11:15 PM";
and -------
I have to do sorting on the basis of startDate.
I have used number of sorting's earlier like numerical.. alphabetical sorting etc via this method:
-(NSMutableArray*)SortEventsArray:(NSMutableArray*)arrayToSort :(NSString*)sortExpression
{
NSSortDescriptor *mySorter = [[NSSortDescriptor alloc] initWithKey:sortExpression ascending:YES];
[arrayToSort sortUsingDescriptors:[NSMutableArray arrayWithObject:mySorter]];
return arrayToSort;
}
but its not working for Date string.
Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看此内容
这也是
两者都会帮助你。
Chekout this
This one also
Both will help you.