我有一组包含关键字的对象(字典)
@"Category"
。我必须按一个特定的键排序,以该键开头。例如,如果
objects[@"Category"]: A, B ,C ,D ,E ,F ,G , H etc.
当用户选择“按C排序”时,我需要按对象重新排序根数组
[@"Category"]
至:C、D、E、F、G、H、A、B-或-C、A、B、D、C、F、C、H。
我希望清楚我的目标是什么
// sortedPosts2 = [self.objects sortedArrayUsingComparator:^(PFObject *object1, PFObject *object2) {
// return [object1[@"Category"] compare:object2[@"Category"] options:NSOrderedAscending];
// }];
// NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:category ascending:YES];
// sortedPosts2 = [self.objects sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationTop];
}