iphone-对一系列字典进行排序

iphone-对一系列字典进行排序,iphone,ipad,Iphone,Ipad,我的应用程序有3种对象:A、B和C。每个对象由一个字典表示,如下所示: NSDictionary *oneObject = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:i], @"number", [NSString stringWithString:@"A", @"kind", //this can be A, B or C [NSNumber numberWithBool:YE

我的应用程序有3种对象:A、B和C。每个对象由一个字典表示,如下所示:

NSDictionary *oneObject = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithInt:i], @"number",
    [NSString stringWithString:@"A", @"kind", //this can be A, B or C
    [NSNumber numberWithBool:YES], @"used", // YES or NO
    [NSString stringWithString:oneName, @"name",
    nil];
NSMutableArray *listOfObjects = [NSMutableArray arrayWithObjects:
     oneObject1, oneObject2 ..etc.. , nil];
这样的对象存储在如下数组中:

NSDictionary *oneObject = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithInt:i], @"number",
    [NSString stringWithString:@"A", @"kind", //this can be A, B or C
    [NSNumber numberWithBool:YES], @"used", // YES or NO
    [NSString stringWithString:oneName, @"name",
    nil];
NSMutableArray *listOfObjects = [NSMutableArray arrayWithObjects:
     oneObject1, oneObject2 ..etc.. , nil];
所以,我有一个可变的字典数组

现在我想对这个可变数组进行排序,按照以下顺序获得一个新数组

1) all objects A
2) all objects B
3) all objects C
所有对象都按其类别进行排序。。。差不多

object A, apple
object A, banana
object A, orange
object B, car
object B, donkey
object B, phone
object B, zebra
object C, ant
object C, box
object C, cigar
object C, hotel
object C, lamb
我的意思是,每个类别都是按对象名称排序的,但整个数组是按类别类别排序的

我该怎么做?
感谢您的帮助。

使用相同的方法,您可以在此处修改比较函数以执行所需操作:

要返回一个单独的数组,您很可能需要创建当前数组的副本,然后对该副本进行排序。然后你会有两个,你的原件和你的复印件