NSSortDescriptor in Swift

前端 未结 7 1664
长情又很酷
长情又很酷 2021-02-02 01:18

I am working on an iOS app and I have data stored in CoreData that I am loading into a UITableView. The data entities have an attribute called id which is a string

7条回答
  •  暖寄归人
    2021-02-02 01:59

    For Swift3

    key is

    result: Bool = 0 < "string1".localizedCompare("string2").rawValue
    

    Use like this

    [some string array].sorted { return 0 < "string1".localizedCompare("string2").rawValue }
    

提交回复
热议问题