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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:22:13+00:00 2026-06-01T13:22:13+00:00

I have a JSON string as the following; { 1: { name: Jerry, age:

  • 0

I have a JSON string as the following;

{
    "1": {
        "name": "Jerry",
        "age": "12"

    },
    "2": {
        "name": "Bob",
        "age": "16"

    "3": {.....
}

I have shown only 2 records but there will be a 100 of records in this JSON. There is an order in this 1,2,3 etc is the order number of the records.

I am ordering these records (as in displaying the 1st record, and then 2nd and 3rd and so forth). My code is provided below.

There is a problem here, when ever i have more than 10 records it doesn’t display records in assending order. It first shows 1 and then 11,12,13… up to 19. Then it shows 2 and then 21,22,23 …. unto 29.

My code is as follows, how can i modify it to solve my issue ?

possible solution : if we could add a leading 0 in from of the numbers that are less than 10, it should filter out correctly. But i know that this is not the correct approach.

NSDictionary *dic = content;

            self.mutArr = [[NSMutableArray alloc] init];

            NSArray *array = [dic allKeys];
            NSArray * sortedArray = [array sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];

            for (NSString *str in sortedArray)
            {
                NSDictionary *dic2 = [dic objectForKey:str];
                Person *person = [[Person alloc] init];            
                person.nameOfRestaurant=[dic2 objectForKey:@"name"];
                person.personStartDate=[dic2 objectForKey:@"age"];

                [self.mutArr addObject:person];

            }

            self.personEntries = [NSArray arrayWithArray:self.mutArr];
  • 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-01T13:22:15+00:00Added an answer on June 1, 2026 at 1:22 pm

    This is because you are sorting numbers lexicographically (i.e. as if they were words). You should provide your own implementation of the sort comparer that converts strings to integers, and only then compares them for ordering.

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

Sidebar

Related Questions

I have the following string from a REST JSON response: [ { uid:10512213, name:Bob
I have a JSON string with the multiple instances of the following Name Message
I have the following json string: {response:[[{uid:123456,name:LA_}],[{cid:1,name:Something}],[{cid:1,name:Something-else}]]} How can I get Something value? I
I have the following JSON object as a String: [{Add1:101,Description:null,ID:1,Name:Bundesverfassung,Short:BV},{Add1:220,Description:null,ID:2,Name:Obligationenrecht,Short:OR},{Add1:210,Description:null,ID:3,Name:Schweizerisches Zivilgesetzbuch,Short:ZGB},{Add1:311_0,Description:null,ID:4,Name:Schweizerisches Strafgesetzbuch,Short:null}] Now i
I have the following JSON schema { employee: {display_name:EMPLOYEE NAME:, format:string, type:textbox, dflt:null, isMandatory:true}
I have a single array json string containing data: [{Name:John,Age:22}, {Name:Jack,Age:56}, {Name:John,Age:82}, {Name:Jack,Age:95}] I
I have a JSON string in a MemoryStream. I am using the following code
I have converted my Datatable to json string use the following method... public string
I have the following code, where message is a JSON String. I am trying
I have the following JSON: {workspace: { name:Dallas, dataStores:http://.....:8080/geoserver/rest/workspaces/Dallas/datastores.json, coverageStores:http://.....:8080/geoserver/rest/workspaces/Dallas/coveragestores.json, wmsStores:http://....:8080/geoserver/rest/workspaces/Dallas/wmsstores.json}} And I´m trying

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.