I am trying to convert an Int
array to an Int
number. What I am now
doing is converting it to a String
array and then use the joined()
function. Is there a more efficient way to do this?
Example:
let sortedIntArray = String(number).characters.map{Int(String($0)) ?? 0}.sorted(by: { $0 > $1 })
let desOrder = Int(sortedIntArray.map{String($0)}.joined())!