Use sort for multidimensional array (array in array) in Swift?

前端 未结 4 1605
萌比男神i
萌比男神i 2021-01-20 06:18

I want to know that how can we use sort or sorted function for multidimensional array in Swift?

For example theirs an array:



        
4条回答
  •  粉色の甜心
    2021-01-20 07:08

    in Swift 3,4 you should use "Compare". for example:

    let sortedArray.sort { (($0[0]).compare($1[0]))! == .orderedDescending }
    

提交回复
热议问题