数组中有字典的排序

.数组中有字典的排序:
    NSMutableArray *myMutableArr = [[[NSMutableArray alloc] init] autorelease];
    NSDictionary *dicOne = [NSDictionary dictionaryWithObjectsAndKeys:@"1",@"price",@"2",@"number", nil];
    NSDictionary *dicTWo = [NSDictionary dictionaryWithObjectsAndKeys:@"6",@"price",@"5",@"number", nil];
    NSDictionary *dicThree = [NSDictionary dictionaryWithObjectsAndKeys:@"3",@"price",@"1",@"number", nil];
    NSDictionary *dicFour = [NSDictionary dictionaryWithObjectsAndKeys:@"4",@"price",@"3",@"number", nil];
    [myMutableArr addObject:dicOne];
    [myMutableArr addObject:dicTWo];
    [myMutableArr addObject:dicThree];
    [myMutableArr addObject:dicFour];
    
    NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"price" ascending:YES]];
    [myMutableArr sortUsingDescriptors:sortDescriptors];
    NSLog(@"排序后的数组%@",myMutableArr);

你可能感兴趣的:(Function,method)