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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:48:52+00:00 2026-06-12T16:48:52+00:00

I have problem with my sort descriptor. I am fetching a ranking of a

  • 0

I have problem with my sort descriptor. I am fetching a ranking of a football club. This is how my webservice gives the data back.

"ranking": [

    {
        "type": "competitie",
        "position": "1",
        "name": "Club Brugge",
        "gamesPlayed": "10",
        "gamesWon": "6",
        "gamesTied": "4",
        "gamesLost": "0",
        "goalsPos": "25",
        "goalsNeg": "12",
        "goalsDiff": 13,
        "points": "22"
    }

Here is my fetch request.

- (void)getKlassement // attaches an NSFetchRequest to this UITableViewController
{
    NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Klassement"];
    request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"position" ascending:YES]];

    self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request
                                                                        managedObjectContext:self.genkDatabase.managedObjectContext
                                                                          sectionNameKeyPath:nil
                                                                                   cacheName:nil];

}

Now the ranking is the following. 1,11,12,13,14,2,3,4,5…
I think the problem is that position is a String in my webservice. And my sort descriptor is looking at it as a string. But actually it should look at it as an integer. Does anybody knows how I can do this ?

Thanks in advance.

  • 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-12T16:48:53+00:00Added an answer on June 12, 2026 at 4:48 pm

    Even if the “position” is provided as a string from your web service, the best solution would be to store it as number (“Integer 32” or similar) in the Core Data model. The corresponding property of the object will be NSNumber and it will be sorted correctly.

    If you really cannot go this way, you could as a workaround try to use localizedStandardCompare as comparison function. I think that sorts strings containing numbers according to their numeric values.

    [NSSortDescriptor sortDescriptorWithKey:@"position" ascending:YES
        selector:@selector(localizedStandardCompare:)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can anyone help, i have problem doing a sort, I thought i had it
i have one problem when i sort the NSMutablearray using date and time wise.
I have a little problem about the sort direction of a specific column in
I currently have a problem within PHP where I want to sort these posts
I have a problem with sorting... I need to sort NSArray containing NSDictionaries .
I have some sort of problem, when it comes to customizing the iPad-launch-lcreens of
I have sort of a tricky problem I'm attempting to solve. First of all,
I have some sort of a design problem with my Django AJAX application. I
I have problem with my query on C, I’m using the oci8 driver. This
I'm having problem how to formulate NSPredicate to get correct data. I have three

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.