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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:40:10+00:00 2026-06-04T04:40:10+00:00

Currently in my app I have a NSArray that I load from NSUserDefaults. Each

  • 0

Currently in my app I have a NSArray that I load from NSUserDefaults. Each object in the NSArray is a NSDictionary that has about 5 different keys. I am re-order the NSDictionarys themselves based upon the NSDates inside of them. I do not want to sort the NSDates alone.

I have tried to do this with this code:

NSComparator sortByDate = ^(id dict1, id dict2) {
        NSDate* n1 = [dict1 objectForKey:@"Date"];
        NSDate* n2 = [dict2 objectForKey:@"Date"];
        return (NSComparisonResult)[n1 compare:n2];
    };
    [self.cellArray sortUsingComparator:sortByDate];

Although nothing happens even though the code gets executed. I am confused though about how to re-order the NSDictionarys based upon something inside of it.

Can anyone offer any insight on this?

Thanks!

  • 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-04T04:40:11+00:00Added an answer on June 4, 2026 at 4:40 am

    You could try sorting it inline but I doubt that would have any major effect. But I can say i never abstract out my blocks. I would definitely try NSLogging too to make sure you’re getting valid NSDates.

        [cells sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
            NSDate *n1 = [obj1 objectForKey:@"Date"];
            NSDate *n2 = [obj2 objectForKey:@"Date"];
    
            if (n1 > n2) {
                return NSOrderedAscending;
            } else (n1 < n2) {
                return NSOrderedDescending;
            } else {
                return NSOrderedSame;
            }
    
        }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a NSMutableArray that loads from NSUserDefaults in my app and feeds
I currently have an app that requires connection to a server in multiple activities.
We have an app that currently installs itself into 'program files\our app', and it
I have a web app that currently is inserting x (between 1 + 40)
I have custom classes that I currently instantiate within App.xaml as resources. I want
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
Basically, I want to have an app with only one view that has an
I'm building an iPhone app that aggregates data from several different data sources and
I have an app that loads while a 2 second movie plays. Currently the
In my app, I have a UITableView that is populated by Core Data, currently

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.