2013-10-26 18 views
-2

我想對這個數組進行排序。按字母順序在標題子字典的_content字段中按升序排列。無法對ios中的數組進行排序,數組包含數字字典和每個字典conatin子字典

任何簡單的解決方案,應該感激。

$1 = 0x0a2654c0 <__NSArrayM 0xa2654c0>(
    { 
     "can_comment" = 0; 
     "count_comments" = 0; 
     "count_views" = 0; 
     "date_create" = 1382375149; 
     "date_update" = 1382375192; 
     description =  { 
      "_content" = ""; 
     }; 
     farm = 4; 
     id = 72157636802321975; 
     "needs_interstitial" = 0; 
     photos = 3; 
     primary = 10406280064; 
     secret = 9731b9f97a; 
     server = 3767; 
     title =  { 
      "_content" = Outdoors; 
     }; 
     videos = 0; 
     "visibility_can_see_set" = 1; 
    }, 
    { 
     "can_comment" = 0; 
     "count_comments" = 0; 
     "count_views" = 0; 
     "date_create" = 1382374546; 
     "date_update" = 1382374548; 
     description =  { 
      "_content" = ""; 
     }; 
     farm = 8; 
     id = 72157636801994055; 
     "needs_interstitial" = 0; 
     photos = 10; 
     primary = 10406216685; 
     secret = 484f085b6d; 
     server = 7420; 
     title =  { 
      "_content" = Cuba; 
     }; 
     videos = 0; 
     "visibility_can_see_set" = 1; 
    }, 
    { 
     "can_comment" = 0; 
     "count_comments" = 0; 
     "count_views" = 0; 
     "date_create" = 1382374276; 
     "date_update" = 1382374279; 
     description =  { 
      "_content" = ""; 
     }; 
     farm = 3; 
     id = 72157636802362284; 
     "needs_interstitial" = 0; 
     photos = 6; 
     primary = 10406175565; 
     secret = f063b11d3e; 
     server = 2839; 
     title =  { 
      "_content" = Afghanistan; 
     }; 
     videos = 0; 
     "visibility_can_see_set" = 1; 
    }, 
    ..... 
there are more than 50 element 

回答

0

試試這個

NSArray *sortedArray = [unsortedArray sortedArrayUsingDescriptors:[NSArray arrayWithObjects:[NSSortDescriptor [email protected]"description._content" ascending:YES],nil]; 
+0

感謝名單哥們這就像魅力 –

+0

工作它不NSMutableArray的unsortedArray工作 –