Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

Thread: Sorting NSArray
View Single Post
Old 09-06-2008, 08:28 PM   #3 (permalink)
myersn024
Tutorial Author
 
Join Date: May 2008
Posts: 315
Default

I use NSSortDescriptors to sort my arrays, but there are other ways. The following code is an example.

Code:
NSSortDescriptor *lastNameDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES];
[peopleArray sortUsingDescriptors:[NSArray arrayWithObject:lastNameSorter]];
In the in the NSSortDescriptor alloc-init line, you'll have to change the initWithKey parameter from lastName to whatever the name of your last name variable is. You'll also have to have a property declared for your last name variable before you can use is as a key.
myersn024 is offline   Reply With Quote
 

» Advertisements
» Online Users: 656
15 members and 641 guests
chits12345, ckgni, Dani77, Domele, drewrico, handmachine, Harisstimolth5, JamesCahall, Janyeok, mistergreen2011, Monstertaco, noobAppDeveloper, Oral B, rimap123, salehamahbub
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,791
Threads: 89,205
Posts: 380,604
Top Poster: BrianSlick (7,129)
Welcome to our newest member, salehamahbub
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:33 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.