沧海一幻觉
最简单的方法是提供一个排序选择器(苹果的文档详情)目标-CsortedArray = [anArray sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];斯威夫特let descriptor: NSSortDescriptor = NSSortDescriptor(key: "YourKey", ascending: true, selector: "localizedCaseInsensitiveCompare:")
let sortedResults: NSArray = temparray.sortedArrayUsingDescriptors([descriptor])Apple为字母排序提供了几个选择器:compare:caseInsensitiveCompare:localizedCompare:localizedCaseInsensitiveCompare:localizedStandardCompare:斯威夫特var students = ["Kofi", "Abena", "Peter", "Kweku", "Akosua"]students.sort()print(students)// Prints "["Abena", "Akosua", "Kofi",
"Kweku", "Peter"]"参照系