Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var mutable_array: [Int] = [ 2, 8, 10, 3, 6, 5, 4, 7, 1, 9]
mutable_array.sortInPlace()
{
let pares: (lhs: Bool, rhs: Bool) = (lhs: ($0 % 2 == 0), rhs: ($1 % 2 == 0))
switch pares
{
case (true, false):
return false
case (false, true):
return true
default:
return $0 < $1
}
}
print(mutable_array.descriptionWithSeparator(", "))
// En la consola de depuración se verá...
// 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.