I have to sort an array of objects by a property of the objects that is a string. How can I do this?
Here's what I ended up using - works like a charm:
[categoryArray sortedArrayWithOptions:0
usingComparator:^NSComparisonResult(id obj1, id obj2)
{
id cat1 = obj1;
id cat2 = obj2;
return [cat1.name compare:cat2.name options:NSCaseInsensitiveSearch];
}];
SelectableCategory
is just a @protocol SelectableCategory
defining the category with all its properties and elements.