Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:35:22+00:00 2026-06-12T06:35:22+00:00

I face the problem, when i sort the dictionary, i can’t get output from

  • 0

I face the problem, when i sort the dictionary, i can’t get output from this.
here i show my NSMutableDictionary which contains.

ReasonMst is my NSMutableDictionary.

Printing description of ReasonMst:
{
1 =     {
    nReasonNo = 1;
    vReasonCode = 1;
    vReasonDesc = "Office Purpose";
    vReasonType = O;
};
10 =     {
    nReasonNo = 10;
    vReasonCode = 10;
    vReasonDesc = Transit;
    vReasonType = O;
};
2 =     {
    nReasonNo = 2;
    vReasonCode = 2;
    vReasonDesc = Personal;
    vReasonType = O;
};
3 =     {
    nReasonNo = 3;
    vReasonCode = 3;
    vReasonDesc = Specific;
    vReasonType = O;
};
4 =     {
    nReasonNo = 4;
    vReasonCode = 4;
    vReasonDesc = "Meeting";
    vReasonType = I;
};
5 =     {
    nReasonNo = 5;
    vReasonCode = 5;
    vReasonDesc = "Meeting arrange";
    vReasonType = I;
};
6 =     {
    nReasonNo = 6;
    vReasonCode = 6;
    vReasonDesc = "NATIONAL CONFERENCE";
    vReasonType = I;
};
7 =     {
    nReasonNo = 7;
    vReasonCode = 7;
    vReasonDesc = Other;
    vReasonType = O;
};
8 =     {
    nReasonNo = 8;
    vReasonCode = 8;
    vReasonDesc = "Briefing Meeting";
    vReasonType = I;
};
9 =     {
    nReasonNo = 9;
    vReasonCode = 9;
    vReasonDesc = "Meeting At HO";
    vReasonType = I;
};
KeyList =     (
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10,
    ""
);
}

i want to sort this NSMutableDictionary to vReasonDesc wise. Can any one tell me how can i do this easiest way ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:35:23+00:00Added an answer on June 12, 2026 at 6:35 am

    Suppose ReasonMst is your NSMutableDictionary, do this

    NSArray *key=[[NSArray alloc]initWithArray:[ReasonMst objectForKey:@"KeyList"]];
    NSMutableArray *vReasonDesc=[[NSMutableArray alloc]init];
    NSMutableArray *sortedKeys=[[NSMutableArray alloc]initWithArray:nil];
    NSDictionary *tempDict=[[NSDictionary alloc]init];
    
    for (int i=0; i<[key count]; i++) {
        [vReasonDesc addObject:[[ReasonMst objectForKey:[key objectAtIndex:i]]objectForKey:@"vReasonDesc"]];
    }
    [vReasonDesc sortUsingSelector:@selector(caseInsensitiveCompare:)];    
    
    for (int i=0; i<[vReasonDesc count]; i++) {
        for (int j=0; j<[key count]; j++) {
            tempDict=[ReasonMst objectForKey:[key objectAtIndex:j]];
            NSLog(@"%@ ... %@",[vReasonDesc objectAtIndex:i], tempDict);
            if ([[tempDict objectForKey:@"vReasonDesc"]isEqualToString:[vReasonDesc objectAtIndex:i]]) {
                [sortedKeys addObject:[tempDict objectForKey:@"vReasonNo"]];
            }
        }
    }
    
    NSLog(@"sdafa %@",sortedKeys);
    

    sortedKeys contain the keys sorted according to your vReasonDesc values… now you can access your ReasonMst according to the keys in sortedKeys which inorder.

    for (int i=0; i<[sortedKeys count]; i++) {
        NSLog (@"%@",[ReasonMst objectForKey:[sortedKeys objectAtIndex:i]]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying some programs in c face a problem with this program can
Copy from drupal.stackexchange.com hoping to get more answers here: I face a rather common
My problem is certainly right on my face but I can't see it... I
i face problem with System.currentTimeMillis( ) in my project i write some code here
I face some problem when I use submit. Here is the code using some
can some one explain why I face problem with backgroundworker backgroundWorker1_RunWorkerCompleted works just fine
Admittedly, this is something of a first world problem, but I'm sort of picky
I am new to iphone developement, during development I face problem due to this
I often face this problem.. Lets say ..In blog application, I need to email
i don't face this problem while working on localhost only when I access the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.