• 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: Sorting an NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting an NSArray


  • Subject: Re: Sorting an NSArray
  • From: Andy Lee <email@hidden>
  • Date: Thu, 30 Jun 2005 01:27:36 -0700

On Jun 30, 2005, at 1:16 AM, Duncan Campbell wrote:
And then I populate an NSArray with objects of this type, is it possible to then sort the array by either the "name" or "address" properties?

Yes. You can use the -sortedArrayUsingXXX methods of NSArray, or if your array is mutable, you can sort it in place with the - sortUsingXXX methods of NSMutableArray.


Example:

NSArray *sortedArray =
    [oldArray sortedArrayUsingSelector:@selector(name)];

--Andy

_______________________________________________
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: Sorting an NSArray
      • From: Andy Lee <email@hidden>
References: 
 >Sorting an NSArray (From: Duncan Campbell <email@hidden>)

  • Prev by Date: Re: Sorting an NSArray
  • Next by Date: Re: Sorting an NSArray
  • Previous by thread: Re: Sorting an NSArray
  • Next by thread: Re: Sorting an NSArray
  • Index(es):
    • Date
    • Thread