I have an array populated with instances of a custom class that contains two String properties, first and last name. Both have a getter method that is equal to the name of the property itself. There is also a method for retrieving the full name of a person called "getFullName". Consider the example below.
CustomClass *person = [[CustomClass alloc] ...]; person.firstname // Returns "Thomas" person.lastname // Returns "Meier" [person getFullName] // Returns "Thomas Meier"
Now I would like to sort this array by name in descending order. I looked at some methods for sorting arrays, but couldn't figure out how to do this. I suppose that I need to create some kind of comparison function that compares two elements, but how can I tell the SDK which values ββto pass to this method and where to place it (in a custom class or in a class where sorting takes place?). Maybe there is another way? Admittedly, I have almost no experience in sorting arrays.
Many thanks for your help!
Ps. The code should work on iOS 3.2
Robin source share