Swift: Sort array of objects alphabetically

前端 未结 7 1064
梦如初夏
梦如初夏 2020-12-12 12:20

I have this:

class Movies {
  Name:String
  Date:Int
}

and an array of [Movies]. How do I sort the array alphabetically by name? I\'ve trie

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 12:56

    Most of these answers are wrong due to the failure to use a locale based comparison for sorting. Look at localizedStandardCompare()

提交回复
热议问题