How to sort a NSArray alphabetically?

前端 未结 7 1096
借酒劲吻你
借酒劲吻你 2020-11-22 15:32

How can I sort an array filled with [UIFont familyNames] into alphabetical order?

7条回答
  •  感情败类
    2020-11-22 16:15

    Another easy method to sort an array of strings consists by using the NSString description property this way:

    NSSortDescriptor *valueDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES];
    arrayOfSortedStrings = [arrayOfNotSortedStrings sortedArrayUsingDescriptors:@[valueDescriptor]];
    

提交回复
热议问题