【发布时间】:2014-10-10 07:27:04
【问题描述】:
我想根据数组 self.contacts 中的 first_name 对我的主数组进行排序
用于对数组进行排序的代码
-(void)Sort
{
NSSortDescriptor *sdName = [[NSSortDescriptor alloc] initWithKey:@"first_name" ascending:YES];
self.contacts = [NSMutableArray arrayWithArray:[self.contacts sortedArrayUsingDescriptors:[NSArray arrayWithObjects:sdName, nil]]];
}
我的数据
self.contacts = (
{
contact = {
"first_name" = "Test R";
};
"last_met" = (
{
"last_met_date" = "2014-10-09";
}
);
},
{
contact = {
"first_name" = "Test K";
};
"last_met" = (
{
"last_met_date" = "2014-10-09";
}
);
}
)
【问题讨论】:
-
请添加更多信息。你的问题很模糊。
标签: objective-c xcode nsarray nssortdescriptor