简体   繁体   中英

NSSortDescriptor Not Sorting Array

I am using NSSortDescriptor to sort my array on the basis of a key. Yesterday the same code was working very fine. But today its not sorting my array. I dont know what happened. There is not even a single code change.

Here is my code

NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:keyName ascending:is_asc];
NSArray *temp = [arrayDFRValues sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]];
arrayDFRValues = [NSMutableArray arrayWithArray:temp];
[self.myTableView reloadData];

Please anyone can help?

NSSortDescriptor * sort = [[NSSortDescriptor alloc] initWithKey:@"keyName" ascending:YES];
NSArray *sortDesc = [NSArray arrayWithObject:sort];
[arrayDFRValues sortUsingDescriptors:sortDesc];
[self.myTableView reloadData];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM