我需要显示我从解析器中获取的名称列表。我正在获取列表的NSMutable列表,然后我需要按字母顺序显示它们。
我尝试做的是:
NSArray *myArtistArray=[[NSArray alloc]init];
myArtistArray=[artistsList sortUsingSelector:@selector(compare:) ];
// error void value not ignored as it outght to be
[myArtistArray sortedArrayUsingSelector:@selector(compare:)];
答案 0 :(得分:8)
[yourMutableArray sortUsingSelector:@selector(compare:)];
[yourArray sortedArrayUsingSelector:@selector(compare:)];
答案 1 :(得分:4)
[yourMutableArray sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
答案 2 :(得分:2)
NSArray *arraysort=[[NSArray alloc] initWithObjects:@"z",@"v",@"a",@"g",@"b", nil];
NSArray *sortedArray = [arraysort sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
for (NSString *str in sortedArray) {
NSLog(@"string %@ ",str);
}
NSLog(@"sortedarrayelements %d",[sortedArray count]);
答案 3 :(得分:2)
[yourArrayName sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];