iphone - Applying a sort to NSArray of custom objects -
i have array of custom objects (really nsset stored in core data becomes nsarray allobjects) , each of these custom objects listitem
. each listitem
belongs list
, has uniqueid. each listitem
has different uniqueid uniqueid of list
belongs + number. if id of list
object @"foo", listitems
each have property listitem1.id = @"foo0", listitem2.id = @"foo1", listitem3.id = "foo2" etc..
so, how can sort array of custom objects based on number appended uniqueid on each listitem?
nsarray *sortedarray = [unsortedarray sortedarrayusingcomparator:^(listitem *obj1, listitem *obj2){ return [obj1.id compare:obj2.id]; }];
Comments
Post a Comment