我有一个带有3个类别的UITableView。我正在使用此代码:
NSArray *arrayOne = [NSArray arrayWithObjects: @"one", @"two", "three", "four", nil];
NSDictionary *dictOne = [NSDictionary dictionaryWithObject:arrayOne forKey:@"Elements"];
每个类别。
我如何按字母顺序对它们进行排序?我在这里读了一些答案,但我没有发现任何东西。
如果我使用此答案Method for sorting custom objects alphabetically in UITableView中的代码,则无效。 我有代码:
[listObjects addObject:dictOne];
如果我把
[listOfTitles sortUsingDescriptors:[NSArray arrayWithObject:titleSorter];
它不起作用。
任何帮助表示赞赏
答案 0 :(得分:9)
NSArray *arrayOne = [NSArray arrayWithObjects: @"one", @"two", "three", "four", nil];
NSArray *sortedArray = [arrayOne sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
NSDictionary *dictOne = [NSDictionary dictionaryWithObject:sortedArray forKey:@"Elements"];