objective c - Sort NSMutableArray by date and then by alphabetical order -


i have nsmutable array of objects. objects represent football (soccer) matches , have nsstring parameter called title (ed "arsenal v chelsea"), , nsdate parameter called actualdate.

i sorting array date @ moment using following code:

nsmutablearray* = [self getmatchlistfromurl:@"http://www.url.com"]; [a sortusingdescriptors:@[[nssortdescriptor sortdescriptorwithkey:@"actualdate" ascending:yes]]]; 

obviously there multiple games happen on same date. sort games happen on same date in alphabetical order. there simple way this?

the method sortusingdescriptors takes array of nssortdescriptor argument. can pass multiple sort descriptors method follow:

nssortdescriptor *sortalphabetical = [nssortdescriptor sortdescriptorwithkey:@"title" ascending:yes]; nssortdescriptor *sortbydate = [nssortdescriptor sortdescriptorwithkey:@"actualdate" ascending:yes]; nsarray *sortdescriptors = @[sortalphabetical, sortbydate]; //perform sorting [a sortusingdescriptors:sortdescriptors]; 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -