无法在ios中排序数组,数组包含字典数,每个字典包含子字典

时间:2013-10-26 05:28:14

标签: ios arrays sorting

我想对这个数组进行排序。按字母顺序按标题子字典的_content字段按升序排列。

$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

1 个答案:

答案 0 :(得分:0)

试试这个

   NSArray *sortedArray = [unsortedArray sortedArrayUsingDescriptors:[NSArray arrayWithObjects:[NSSortDescriptor sortDescriptorWithKey@"description._content" ascending:YES],nil];