I have an NSArray as follows:
NSArray *directoryContent = [[NSFileManager defaultManager] directoryContentsAtPath:filePath];
The files at filePath are:
11.thm, 12.thm, 13.thm,…,Text_21.thm, Text_22.thm, Text_23.thm,…
I would like to sort the NSArray in the order:
13.thm, 12.thm, 11.thm,…, Text_23.thm, Text_22.thm, Text_21.thm,…
How do I achieve this?
Write a custom sorting function:
and use it like this:
I have made many assumption, but this code works on your sample array and similar input values.
The main assumption is that you wanted this particular order only for strings that start with a numeric value. If it’s not the case, you can use this code to adapt it to the algorithm you want.