2012-04-26 11 views
2

辞書とそのサブ辞書を含むnsmutablearrayの並べ替えに問題があります。以下は私のnsmutablearrayです。私はactualScoreキーを使用してこの配列を並べ替える必要があります。サブ辞書キーを使用した並べ替え

sorteddictioary:(
    { 
    "0:Present and past" =   (
        { 
      SubUnit = "Present simple (\U2018I do\U2019)"; 
      SubUnitExercise = "Exercise 2"; 
      SubUnitExerciseProgress = "<SubUnitExerciseProgress: 0x777d8d0> (entity: TSubUnitExerciseProgress; id: 0x77d2710 <x-coredata://1ADCDF30-EC80-4B40-8A9E-58BA0532D014/TSubUnitExerciseProgress/p1> ; data: {\n actualScore = 6;\n editDate = \"2012-04-25 13:22:38 +0000\";\n subUnitExercise = \"0x7784270 <x-coredata://1ADCDF30-EC80-4B40-8A9E-58BA0532D014/TSubUnitExercise/p2>\";\n time = \"106.246\";\n totalScore = 10;\n})"; 
     } 
    ); 
    "14:Prepositions" =   (
        { 
      SubUnit = "\U2018By\U2019"; 
      SubUnitExercise = "Exercise 2"; 
      SubUnitExerciseProgress = "<SubUnitExerciseProgress: 0x77a9000> (entity: TSubUnitExerciseProgress; id: 0x778d910 <x-coredata://1ADCDF30-EC80-4B40-8A9E-58BA0532D014/TSubUnitExerciseProgress/p2> ; data: {\n actualScore = 7;\n editDate = \"2012-04-26 05:54:45 +0000\";\n subUnitExercise = \"0x77dc1c0 <x-coredata://1ADCDF30-EC80-4B40-8A9E-58BA0532D014/TSubUnitExercise/p278>\";\n time = \"63.06152\";\n totalScore = 10;\n})"; 
     } 
    ); 
    "2:Future" =   (
        { 
      SubUnit = "Present tense (\U2018I am doing\U2019/\U2018I do\U2019) for the future"; 
      SubUnitExercise = "Exercise 1"; 
      SubUnitExerciseProgress = "<SubUnitExerciseProgress: 0x77762d0> (entity: TSubUnitExerciseProgress; id: 0x778d920 <x-coredata://1ADCDF30-EC80-4B40-8A9E-58BA0532D014/TSubUnitExerciseProgress/p3> ; data: {\n actualScore = 0;\n editDate = \"2012-04-26 07:22:23 +0000\";\n subUnitExercise = \"0x81e6e70 <x-coredata://1ADCDF30-EC80-4B40-8A9E-58BA0532D014/TSubUnitExercise/p46>\";\n time = \"113.5866\";\n totalScore = 10;\n})"; 
     } 
    ); 
} 

誰もがサブ辞書と辞書を持つnsmutable、アレイ上にソートする方法を知っています。

答えて

1

はこれを試してみてください:

NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"SubUnitExerciseProgress.data.actualScore" 
                  ascending:YES]; 

[initialArray sortUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]]; 
NSMutableArray* sortedArray = [initialArray mutableCopy]; 
+0

ITSは機能していません。.. – Ketan

関連する問題