reorder NSArray in objective-c
I have an NSArray of JSON file locations. There are stored in the 开发者_Python百科user's/app's Document directory and inside each JSON file is a name value.
I'm able to retreive the data from JSON files, I don't need help with tht. But I need help on sorting NSArrays I have no idea how I can do that based on a value inside the file, while not being pathetically slow.
This is on the iPhone btw.
In sum how do I customly reorder NSArrays.
NSArray contents are immutable, but there are several methods for creating a sorted copy of the array, like sortedArrayUsingFunction:context:
, sortedArrayUsingSelector:
or sortedArrayUsingDescriptors:
Note that the new sorted array does not copy the elements of the original done, it just retains them.
精彩评论