0

2 つのオブジェクトを持つ配列があり、各オブジェクトには 31 個のキーがあります。@"FirstName" をテーブルビューのアルファベット順に表示しています。今私の問題は、@"FirstName" に従って他のキーを配置する方法です。配列を名でソートしたい。

以下は、にロードしている Web サービスからの応答ですNSMutableArray

(NSMutableArray *) $2 = 0x002afa40 <__NSArrayM 0x2afa40>
{
    AtQRid = "Hiiiiiiiii\n";
    City = HKJH;
    Company = BMBJ;
    Email = HJKHJKH;
    EmailStatus = KJHK;
    EventID = HJBJHGH;
    FBStatus = KJHK;
    FirstName = JHGHGJKBN;
    FollowUPDate = HJHKJ;
    FollowUPTypeID = KH;
    ImageURL = VGHV;
    LastName = MBN;
    LeadID = H;
    LinkedinStatus = HKH;
    Notes = JKHKH;
    PhoneNo = HJK;
    Rating = KJNK;
    ReminderStatus = KJHK;
    SalesForceStatus = KJHK;
    State = HJHKH;
    SurveyQAnswer1 = KJ;
    SurveyQAnswer2 = HKH;
    SurveyQAnswer3 = KJ;
    SurveyQAnswer4 = HK;
    SurveyQuestion1 = KHK;
    SurveyQuestion2 = JHK;
    SurveyQuestion3 = HH;
    SurveyQuestion4 = KJ;
    SyncStatus = HKJKH;
    TwitterStatus = KHJK;
    UserID = KJBNMN;
},
{
    AtQRid = "byeeeeeeeeeeeeeeeeeee\n";
    City = hyd;
    Company = GlobalNest;
    Email = "abhi_norules@yahoo.com";
    EmailStatus = hahahahah;
    EventID = 7689;
    FBStatus = "hey guys";
    FirstName = Abhishek;
    FollowUPDate = 3849934;
    FollowUPTypeID = kjsndjkvndsk;
    ImageURL = "www.image.com";
    LastName = Naidu;
    LeadID = 123456789;
    LinkedinStatus = "good looking ";
    Notes = "fksd jsdk skdj sdkjks dksjd dmndsn dksndskjkdj gkdjk jdkjdsk sdjksjsdn msd sdnsdnksdjksdjksd sdkn dsmsdnm sd";
    PhoneNo = 84377847549;
    Rating = 5star;
    ReminderStatus = kjsdjsdf;
    SalesForceStatus = "i donno";
    State = ap;
    SurveyQAnswer1 = jshdsdjfh;
    SurveyQAnswer2 = kjshfjkhf;
    SurveyQAnswer3 = kjsdjsdnn;
    SurveyQAnswer4 = kjnsjdvnds;
    SurveyQuestion1 = jsdkfds;
    SurveyQuestion2 = "kjnsdv,";
    SurveyQuestion3 = kjskdvk;
    SurveyQuestion4 = jskd;
    SyncStatus = jnsdnmsdm;
    TwitterStatus = "hey hi";
    UserID = 3456;
}
4

1 に答える 1

3
NSSortDescriptor *descriptor = [NSSortDescriptor 
   sortDescriptorWithKey:@"FirstName" ascending:YES];
NSArray *sortedArray = [originalArray sortedArrayUsingDescriptors:
   [NSArray arrayWithObject:descriptor]];
于 2012-08-06T08:02:46.793 に答える