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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:00:18+00:00 2026-05-15T17:00:18+00:00

Hello I have an array of persons, and i am trying to sort them

  • 0

Hello I have an array of persons, and i am trying to sort them by age using a sort descriptor.
The age field in a patient is a string so when calling:

ageSorter = [[NSSortDescriptor alloc] initWithKey:@"age" ascending:YES];
[personList sortUsingDescriptors:[NSArray arrayWithObject:ageSorter]];

It sorts them but 100 appears first because its is not using numericSearch in the compare options.

Is there a ways i can still sort with descriptor but maybe using a selector to change how to compare the strings?

  • 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-15T17:00:18+00:00Added an answer on May 15, 2026 at 5:00 pm

    The finderSortWithLocale method (both these are taken from apple api):

    int finderSortWithLocale(Person *person1, Person *person2, void *locale)
    {
        static NSStringCompareOptions comparisonOptions = NSNumericSearch;
    
        NSRange string1Range = NSMakeRange(0, [string1 length]);
        NSString *age1 = person1.age;
        NSString *age2 = person2.age;
        return [age1 compare:age2
                        options:comparisonOptions
                        range:string1Range
                        locale:(NSLocale *)locale];
    }
    

    How to call this method (edited: call the function on array of Persons):

        NSArray *sortedArray = [personList sortedArrayUsingFunction:finderSortWithLocale
                                             context:[NSLocale currentLocale]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello everybody I have a question: I have a array String[] parte and I
Hello I have an array $name[] that I am trying to insert into the
I have an array that I want to find the number of string 'hello'
Let's say I have these two arrays: string[] arr1 = new string[2]{Hello, Stack} string[]
Hello I have a string in PHP $string = ...................blah blah blah.................. where the
Hello I have an array that looks like this, Array ( [cfi_title] => Mr
I have a string array, and it may contain an element with the text
Hello i have this method: private function findConnectedNodes(node:Node):Array{ var test_node:Node; var surrounding_nodes:Array = [];
I have an array that looks something like this array(7) { [0]=> hello,pat1 [1]=>
Hello i have been trying to find a tutorial that show how to setup

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.