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];