Re: Newbie-Question: Sorting Arrays
Re: Newbie-Question: Sorting Arrays
- Subject: Re: Newbie-Question: Sorting Arrays
- From: Pontus Ilbring <email@hidden>
- Date: Fri, 10 Jun 2005 16:08:45 +0200
On 6/10/05, Christoph Lauterbach <email@hidden> wrote:
> Hi,
>
> I am a newbie to Cocoa, so please be appreciative for my question:
>
> I have an mutable array with objects with contain among others a NSDate
> object and a NSString object.
>
> I want to sort the array in ascending order by the NSDate object and
> secondly by the NSString object.
If I've understood things right you have some kind of class MyClass
whose instances holds those dates and strings.
Read the documentation for NSDate's and NSString's compare: methods.
You'll want to write a similar compare: method for MyClass that
returns the result of comparing the dates, or the result of comparing
the strings if the dates should be equal.
Then you give this method's selector to sortUsingSelector:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden