Occasionally you will come across the need to re-order the contents of an NSArray. One reason could be that you want to put the contents of an NSArray in to a table view, but in a different order to what is currently in the NSArray. This tutorial shows one way (of many) of how this can be done.
The method we will look at in this tutorial is the sortedArrayUsingComparator: which is an instance method from the NSArray class. On first looks, this can look a little complicated, but if you take time to read through and see what is happening, it begins to make perfect sense. It also makes for quite clean code too.
arrayOfObjects = [arrayOfObjects sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
}];