iphone - how to sort an NSArray of nested NSArrays by array count? -
i have nsarray contains nested nsarrays. im looking way sort parent array according object count of nested arrays in ascending order. if [array1 count]
4, [array2 count]
2 , [array3 count]
9, : array2, array1, array3...
there few solutions, 1 of is:
nssortdescriptor *sd = [nssortdescriptor sortdescriptorwithkey:@"@count" ascending:yes]; nsarray *sds = [nsarray arraywithobject:sd]; nsarray *sortedarray = [array sortedarrayusingdescriptors:sds];
Comments
Post a Comment