Я должен отсортировать массив Array с определенным ключом likecount в порядке убывания.Я написал код ниже, и я вижу, что никаких изменений не происходит.Это означает, что сортировка не выполняется.Я упомянул мой вывод консоли ниже.
for (NSDictionary *wallText in wallvalue) {
NSString *wallNameValue = [wallText objectForKey:@"message"];
if(![[NSNull null] isEqual:wallNameValue] && [wallNameValue length])
{
[tableList addObject:wallNameValue];
NSLog(@" Count Like %@",[likeCount objectAtIndex:i]);
dict = [NSDictionary dictionaryWithObjectsAndKeys: @"message", wallNameValue, @"likecount", [likeCount objectAtIndex:i], nil];
[array addObject:dict];
NSLog(wallNameValue);
}
i++;
}
NSSortDescriptor *descriptors=[[[NSSortDescriptor alloc]initWithKey:@"likecount" ascending:YES]autorelease];
NSArray *sortdescriptor=[NSArray arrayWithObject:descriptors];
NSArray *sortedarray=[array sortedArrayUsingDescriptors:sortdescriptor];
NSLog(@"source sorting id key is %@",sortedarray);
NSLog(@"source s@@@@@@ id key is %@",array);
Вывод программы
source id key is (
{
2 = likecount;
"This wall post is not from application. Direct from website." = message;
},
{
0 = likecount;
"New integration" = message;
},
{
1 = likecount;
"This is beta testing.. yes" = message;
},
{
2 = likecount;
"hello wall testing.." = message;
}
)