0

I have to sort objects based on NSDates. What are the options for sorting by NSDate?

1
  • How are the orders stored? NSArray? Do you have an NSArrayController, etc... Commented Feb 25, 2010 at 13:18

2 Answers 2

1

In general you use a NSSortDescriptor to define the sort of collections like arrays or Core Data. You call the sort from the collection object itself.

NSDate itself has comparison functions if you want to do the sort directly yourself.

Sign up to request clarification or add additional context in comments.

Comments

0

You can do sorting of date by comparing two dates.For that you should use. NSComparisonResult class. NSComparisonResult result=[date1 compare:date2];

if result==NSorderSame then date1 and date2 is Same.

result==NSOrderedAscending then date1 is smaller than date2.

result==NSOrderedDescending then date1 is greater than date2.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.