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 7653439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:02:12+00:00 2026-05-31T12:02:12+00:00

I have an NSArray output. please refer below. I want to sort based on

  • 0

I have an NSArray output. please refer below. I want to sort based on particular number field (Order) in it. Please refer the code below.

Log: resultArray:
(
        {
        Name = "Myname1";
        Id = "dummyID";
        Order = 0; 
        parexId = 15;
        "__type" = "Question:#myAPI";
    },
        {
        Name = "Myname2";
        Id = "fatID";
        Order = 1; 
        parexId = 16;
        "__type" = "Question:#myAPI";
    }
        {
        Name = "Myname3";
        Id = "colorID";
        Order = 2; 
        parexId = 17;
        "__type" = "Question:#myAPI";
    }

)

Code:

NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"Order" ascending:YES comparator:^(id obj1, id obj2) { 
            return [obj1 compare:obj2 options:NSNumericSearch]; 
    }];
    resultArray = [resultArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]]; // resultArray contents the above output values.

BUT it is crashing when compare happens during sorting.
Crash error:

-[__NSCFNumber compare:options:]: unrecognized selector sent to instance 0x6b514b0

Could someone please help me, what i’m doing wrong here?

Thank you!

  • 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-05-31T12:02:13+00:00Added an answer on May 31, 2026 at 12:02 pm

    Order is a number field. It does not have method compare:options. You should use

    [obj1 compare:obj2];

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

Sidebar

Related Questions

I have this code NSDictionary *tempDict = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects:@authorId,authorName,authorDescription,@image,nil] forKeys: [NSArray arrayWithObjects:@id,@name,@desc,@image,nil]];
Hi I have the following code: - (IBAction)runTask:(id)sender { NSTask *proc; NSPipe *output; NSData
I have to sort the following array objects in either ascending or descending order.
I have to sort my Array array with specific key likecount with descending order.
I have to sort this array in descening order with the key likecount. How
I have following code NSArray *myArray = [[NSArray alloc] initWithObjects:@1,@2,nil]; NSMutableDictionary *dic0 = [[NSMutableDictionary
I have an NSArray and I'd like to create a new NSArray with objects
I have an NSArray of Foos in an Objective-C program. I would like to
I have an NSArray of (Product) objects that are created by parsing an XML
I have an NSArray of NSDictionary objects which I would like to be able

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.