• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie-Question: Sorting Arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Newbie-Question: Sorting Arrays
      • From: "Christoph Lauterbach" <email@hidden>
References: 
 >Newbie-Question: Sorting Arrays (From: "Christoph Lauterbach" <email@hidden>)

  • Prev by Date: NSSavePanel: Hide extension is killing the extension
  • Next by Date: Re: xcode keeps crashing when i compile
  • Previous by thread: Newbie-Question: Sorting Arrays
  • Next by thread: Re: Newbie-Question: Sorting Arrays
  • Index(es):
    • Date
    • Thread