Ios 当在索引中多一个数组值时 nsarray 排序

Ios nsarray sorting when in index one more array value

我知道对简单数组进行排序,但这很难。我在数组索引值中排序了一个我必须排序的数组参数,以简单的方式我面临一个数组值所以我混淆了如何排序这种类型的区域这是我的数组 这是索引号 0 value ,在此数组名称中是 TODAY 数组值 check_in 参数我必须排序

{

        address = dsfsd;
        allergies = Dsf;
        annotation = Sdf;
        "birth_date" = "0000-00-00";
        "category_id" = 2;
        "child_id" = 3;
        today =         {
            "check_in" = "7:30 AM";
            "check_out" = "7:30 AM";
            "child_id" = 3;
            "children_schedule_id" = 6;
            day = Wednesday;
            "on_off" = 1;
        };
        weight = sdfsd;
        "work_hours" = dsfds;
    },

这是我的代码

 NSSortDescriptor *firstDescriptor = [[NSSortDescriptor alloc] initWithKey:@"today.check_in" ascending:YES];
                  NSArray *sortDescriptors = [NSArray arrayWithObjects:firstDescriptor, nil];
                  aryOne = [getData sortedArrayUsingDescriptors:sortDescriptors];

使用 sortedArrayUsingComparator 进行复杂排序。

NSArray *sortedArray = [array sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
  NSString *checkIn1 = obj1[@"today"][@"check_in"];
  NSString *checkIn2 = obj2[@"today"][@"check_in"];
  // You could convert them to dates or times here if you want. Or just compare the strings.
  return [checkIn1 compare:checkIn2];
}];