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

  • SEARCH
  • Home
  • 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 9026685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:34:57+00:00 2026-06-16T06:34:57+00:00

How to sort this kind of case? I have a NSMutableArray . My NSMutableArray

  • 0

How to sort this kind of case?

  1. I have a NSMutableArray.
  2. My NSMutableArray can have an object or NSMutableDictionary.
  3. My NSMutableDictionary only has 1 object (an object as its object and a string as its key)
  4. Both object is the same and has attribute name

Now, what I’m struggle with is I want to sort the NSMutableArray based on the dictionary key and the object’s name? (let’s just ignore the object that is added to NSMutableArray)

Bunch of thanks to person can give me idea how to solve this case!

  • 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-16T06:34:59+00:00Added an answer on June 16, 2026 at 6:34 am

    Add your NSMutableArray to a custom subclass of NSObject and sort using a custom NSComparator, like so:

    (NSComparator)^(id obj1, id obj2){ /* obj1 and obj2 are NSMutableArrays */
          if ([obj1 objectAtIndex:1] isKindOfClass:[NSMutableDictionary class]) {
               // sort according to the dictionary case
          } else { // [obj1 objectAtIndex:1] isKindOfClass:[NSObject class]
               // sort according to the your other, default case
          }
    }
    

    Do note that this is untested and that you’ll need to fill in the bodies of the if and else statements. The comment by the else clause is just how I code and you can eliminate it if it doesn’t conform to your taste.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I sort this array by the value of the "order" key? Even
Does open function have some sort of restriction as to what kind of string
How to sort this kind of input? 0.00159265291648695254 -0.00318530179313823899 0 0.00999983333416666468 0.00362937767285478371 0.00477794259012844049 -0.00637057126765263261
How can I sort this foreach loop with jQuery? I will sort on id
I know this sort of question has been asked before , but I still
I have a list of objects (Move's in this case) that I want to
I can understand that many years ago there would be this kind of limitation,
I have two situations in this case: I want to query a WCF service
assume I have a table of this kind: A B 3 C D 1
I'm trying to sort a array of this kind : array ( 0 =>

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.