嗨,我有以下字典数组,我想使用键“BirthDate”对数组进行排序,我的代码如下
NSLog(@"nodeEventArray == %@", temp);
NSSortDescriptor *dateDescriptor = [NSSortDescriptor
sortDescriptorWithKey:@"BirthDate"
ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:dateDescriptor];
NSArray *sortedEventArray = [temp
sortedArrayUsingDescriptors:sortDescriptors];
NSLog(@"sortedEventArray == %@", sortedEventArray);
但我无法正确排序,谁能告诉我如何根据“BirthDate”键对字典数组进行排序。因为出生日期是来自服务的字符串
字典样本数组:
nodeEventArray = (
{
BirthDate = "05/04/1986";
Email = "";
FirstName = Test;
IsSpouse = 0;
LastName = Test;
MiddleInitial = "";
PatientID = "";
Phone = "";
ScacntronCSVId = 40409;
SlotID = 1;
UserName = "Tes_02192013010055";
},
{
BirthDate = "02/14/1986";
Email = "";
FirstName = Guest;
IsSpouse = 0;
LastName = Guest;
MiddleInitial = "";
PatientID = "";
Phone = "";
ScacntronCSVId = 40410;
SlotID = 2;
UserName = "Gue_02192013014725";
},
{
BirthDate = "02/17/1987";
Email = "";
FirstName = User;
IsSpouse = 0;
LastName = User;
MiddleInitial = "";
PatientID = "";
Phone = "";
ScacntronCSVId = 40411;
SlotID = 3;
UserName = "Use_02192013020726";
}
)