I have some files in nsdocumentdirectory,when I fetched those file its returns the file with random position.I am using this following code:
NSString *downloadDirectory = [Utility bookDownloadFolder];
NSString *bookFolder = [[_selectedBook.zipFile lastPathComponent] stringByDeletingPathExtension];
NSString *bookFolderFinal = [downloadDirectory stringByAppendingPathComponent:bookFolder];
NSMutableArray *retval = [NSMutableArray array];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSArray *files = [fileManager contentsOfDirectoryAtPath:bookFolderFinal error:&error];
and the output is like this :
files("1.jpg","1.txt","10.jpg","10.txt""11.jpg","11.txt","12.jpg","12.txt","13.jpg","13.txt","2.jpg","2.txt", "3.jpg","3.txt","4.jpg","4.txt","5.jpg","5.txt","6.jpg","6.txt" "7.jpg","7.txt", "__MACOSX" )
But I want the output in ascending order like : files("1.jpg","1.txt","2.jpg","2.txt",)
If I use localizedCaseInsensitiveCompare to sort the array,it is not working in this case,if I use localizedCaseInsensitiveCompare then the output is like this only.( "__MACOSX", "1.jpg", "1.txt", "10.jpg", "10.txt", "11.jpg", "11.txt", "12.jpg", "12.txt", "13.jpg", "13.txt", "2.jpg", "2.txt", "3.jpg", "3.txt", "4.jpg", "4.txt", "5.jpg", )