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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:09:04+00:00 2026-05-24T11:09:04+00:00

I have a simple NSArray which has some arrays as objects which has some

  • 0

I have a simple NSArray which has some arrays as objects which has some dates and strings as objects:

  • NSArray (main array) —————> table view
    • NSArray (secondary array)—> table view cell
      • NSDate ——————–> table view cell text label
      • NSString ——————-> table view cell detail text label
      • etc.

I use the main array for my table view -> each cell got it’s own ‘secondary array’.
Now I want to sort the main array by the NSDate object. It sounds very easy but I have found no solution on the web for it.

I thought about using NSSortDesriptors but those just sort the array by the objects in the main array and not in the secondary array.

Hopefully you can help me

EDIT: Would it fix the problem if I use a NSDictionary as the secondary array?

  • 1 1 Answer
  • 2 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-24T11:09:05+00:00Added an answer on May 24, 2026 at 11:09 am

    You should be able to use NSArray sortedArrayUsingComparator if your app is targeted for iOS 4.0 or later:

    NSArray *sortedArray = [mainArray sortedArrayUsingComparator: ^(id obj1, id obj2) {
        return [[obj1 objectAtIndex:0] compare:[obj2 objectAtIndex:0]];
    }];
    

    This assumes that the date field is always in index 0 of the internal array. It would probably be a bit cleaner if you used a dictionary and keyed the date field by name, but if you are comfortable with the date field always remaining in index 0 then the above should work.

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

Sidebar

Related Questions

I have a simple table view which I have built using an example from
in a simple drawing application I have a model which has a NSMutableArray curvedPaths
I have this simple scenario: main.m (which is my main class) myClass.m (which is
Hi I have created an array from core-data using: NSArray* invoiceItem =[fetchedResultsController fetchedObjects]; which
I have simple SSIS package which reads data from flat file and insert into
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have simple SSIS package in which On Error event handler I have created
I have a Group entity which has many Item entities. An Item entity can
I have a simple protocol with a property: @protocol StopsSource <NSObject> @property (retain,readonly) NSArray
I have a single NSDictionary object which contains a large number of custom objects.

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.