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

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -