如何在UITableView中按降序对数组进行排序?

时间:2015-09-18 17:57:57

标签: ios objective-c nsarray

mutArray = [[NSArray alloc]initWithObjects:@"Titanic",@"Batman",@"Spiderman",@"Avatar",@"Pirates ofcarrrabiean",@"Avengers",@"Harrypotter",@"starwars",@"Lordofrings", nil];

1 个答案:

答案 0 :(得分:0)

试试这个。

NSSortDescriptor *descriptor=[[NSSortDescriptor alloc] initWithKey:@"self" ascending:NO];
NSArray *descriptors=[NSArray arrayWithObject: descriptor];
NSArray *shortedArray=[mutArray sortedArrayUsingDescriptors:descriptors];