This code will not actually change the order. sortedArrayUsingComparator:
returns a whole new array. It doesn't sort an existing array in place. The sorting operation is effectively thrown away -- _bookmarksArray
is never changed. You could, for instance, change it to:
-(void)updateOrder
{
[self willChangeValueForKey:@"bookmarksArray"];
_bookmarksArray = [_bookmarksArray sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
/**
Here is the sort code.
**/
}];
[self didChangeValueForKey:@"bookmarksArray"];
}
(Assuming ARC here. Same idea but with appropriate retain
/release
calls if not ARC.)