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

  • Home
  • SEARCH
  • 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 7700105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:37:51+00:00 2026-05-31T22:37:51+00:00

I have an array unsortedPosts full of dictionaries, which look like this if I

  • 0

I have an array unsortedPosts full of dictionaries, which look like this if I print out the contents in the terminal:

{
    "created_at" = 1332584959;
    id = "61926802418418";
    network = "net1";
    text = "text1";
    url = "https://www.google.com";
},
{
    "created_at" = 1332581096;
    id = "6192689218418";
    network = "net1";
    text = "text1";
    url = "https://www.yahoo.com";
},
{
    "created_at" = 1332581074;
    id = "6192688628418";
    network = "net1";
    text = "text1";
    url = "https://www.aol.com";
}

I want to sort them by the created_at field (unix time stamps). I’m using NSSortDescriptor like so:

NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"\"created_at\"" ascending:TRUE];
NSMutableArray *sortDescriptors = [NSMutableArray arrayWithObject:sortDescriptor];
NSArray *sortedSocialPosts;
sortedSocialPosts = [unsortedSocialPosts sortedArrayUsingDescriptors:sortDescriptors];

But the output isn’t sorted.

Edit

I tried running it without using the escaped quotes around created_at (per @Eimantas answer):

NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"created_at" ascending:TRUE];
NSMutableArray *sortDescriptors = [NSMutableArray arrayWithObject:sortDescriptor];
NSArray *sortedSocialPosts;
sortedSocialPosts = [unsortedSocialPosts sortedArrayUsingDescriptors:sortDescriptors];

But I get this error:

-[__NSCFNumber length]: unrecognized selector sent to instance 0x6a2a3c0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x6a2a3c0'
  • 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-31T22:37:52+00:00Added an answer on May 31, 2026 at 10:37 pm

    You don’t need the escaped quotes, just pass in @"created_at" and you will be good. The quotes are sometimes printed when doing NSLog() calls. I’m pretty sure that you can actually access the creation timestamp just by accessing @"created_at" key with valueForKey: method.

    update

    This may mean that some of the created_at values may be NSString instances and some – NSNumber instances. Can you confirm that all of the created_at values are of the same type? (Use NSLog(@"%@", [[unsortedSocialPosts valueForKey:@"created_at"] valueForKey:@"class"]);.

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

Sidebar

Related Questions

I have array like this: array('1224*', '543*', '321*' ...) which contains about 17,00 "masks"
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
i have array like below which is sorted by array_count_values function, Array ( [Session
I have array like this: $test = array(20, 30, 40); And I want to
I have array like this: $test = array(20, 30, 40); And I want to
I have array that looks like this, Array ( [email_address] => Array ( [0]
I have array like this: array( 'person0' => array( 'name'=>'name0','address'=>'address0' ), 'person1' => array(
Why, if I have array of objects like this: class testClass { private $_x
I have array output like this. { id = 1; user = { name=ABC
I have array like this: [0] => ['lang'] => 'DE', ['message'] => 'some text'

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.