1. Normal array Ordering:
nsmutablearray *arr = [Nsmutablearray arraywithobjects:@ "0", @ "8", @ "6", @ "1",nil]; nsarray *sortedarray = [arr sortedarrayusingcomparator:^nscomparisonresult (ID obj1, id obj2) {if ([Obj1 Intvalue] & Gt [Obj2 Intvalue]) {return nsordereddescending;} if ([Obj1 intvalue] < [obj2 Intvalue]) {return nsorderedascending;} return nsorderedsame;}]; NSLog (@ "sorted array:%@", Sortedarray), 2. The sort of dictionary in the array: Nsmutablearray *mymutablearr = [[ [Nsmutablearray alloc] init] autorelease]; nsdictionary *dicone = [nsdictionary dictionarywithobjectsandkeys:@ "1", @ "price", @ "2", @ "number", nil]; nsdictionary *dictwo = [nsdictionary dictionarywithobjectsandkeys:@ "6", @ "price", @ "5", @ "number", nil]; nsdictionary *dicthree = [nsdictionary dictionarywithobjectsandkeys:@ "3", @ "price", @ "1", @ "number", nil]; nsdictionary *dicfour = [nsdictionary dictionarywithobjectsandkeys:@ "4", @ "price", @ "3", @ "number", nil];  [Mymutablearr addobject:dicone]; [Mymutablearr addobject:dictwo]; [Mymutablearr addobject:dicthree]; [Mymutablearr addobject:dicfour]; Nsarray * Sortdescriptors = [Nsarray arraywithobject:[nssortdescriptor sortdescriptorwithkey:@ "Price" ascending:YES]]; [Mymutablearr sortusingdescriptors:sortdescriptors]; NSLog (@ "sorted array%@", Mymutablearr);
Array sorting (by a key value pair in the dictionary in the array)