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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:04:55+00:00 2026-06-01T03:04:55+00:00

Got a an Array full of dictionary likes this: ( { order = 10;

  • 0

Got a an Array full of dictionary likes this:

(
   { order = "10";
     name = "David"
   };
   { order = "30";
     name = "Jake";
   };
   { order = "200";
     name = "Michael";
   };
)

When i’m using NSSortDescriptor like the code below it only sorts regarding to the first char so 200 is lower then 30. I can of course change the “order” object into a NSNumber instead of string and it would work. But is there a way to sort a string as int values without changing the source object?

NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"norder"  ascending:YES];
[departmentList sortUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]];

Update:

Thanks to bandejapaisa.

Here is the a working version for iOS 5 (Xcode where compalining).

NSArray *sortedArray;
sortedArray = [departmentList sortedArrayUsingComparator:(NSComparator)^(id a, id b) {
    NSNumber *num1 = [NSNumber numberWithInt:[[a objectForKey:@"norder"] intValue]];
    NSNumber *num2 = [NSNumber numberWithInt:[[b objectForKey:@"norder"] intValue]];

    return [num1 compare:num2];
}];
departmentList = [sortedArray mutableCopy];
  • 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-01T03:04:56+00:00Added an answer on June 1, 2026 at 3:04 am

    Maybe sort using a comparator instead, or one of the other sorting methods:

    NSArray *sortedArray = [someArray sortedArrayUsingComparator:^(id obj1, id obj2) {
      NSNumber *num1 = [NSNumber numberWithInt:[obj1 intValue]];
      NSNumber *num2 = [NSNumber numberWithInt:[obj2 intValue]];
      return (NSComparisonResult)[rank1 compare:num2];
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got an array full with items like these: array( array( 'id' =>
I've got a plist (created in XCode) with an array full of Numbers (0.01,
I got an array like that Array ( [0] => Array ( [UnitESN] =>
Say I've got this array: MyArray(0)=aaa MyArray(1)=bbb MyArray(2)=aaa Is there a .net function which
I've got a array of class in which one member is the full path
This question got me today, my repositories should always return full objects? They can
I got data like this: ӘІҢҒҮҰҚӨҺ. hexing this data to this: d398d086d2a2d292d2aed2b0d29ad3a8d2ba then adding
I got an array which I iterate over and try to create a variable.
I got an array which contains signed int data, i need to convert each
If I've got an array of values that are basically zero-padded string representations of

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.