Swift - Sort array of objects with multiple criteria

后端 未结 8 1107
北荒
北荒 2020-11-22 11:19

I have an array of Contact objects:

var contacts:[Contact] = [Contact]()

Contact class:

Class Contact:NSOBjec         


        
8条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 12:01

    that worked for my array[String] in Swift 3 and it seems in Swift 4 is ok

    array = array.sorted{$0.compare($1, options: .numeric) == .orderedAscending}
    

提交回复
热议问题