Skip to content

Instantly share code, notes, and snippets.

@fitomad
Last active November 17, 2015 15:07
Show Gist options
  • Save fitomad/fe21a9ad6d676374a7ba to your computer and use it in GitHub Desktop.
Save fitomad/fe21a9ad6d676374a7ba to your computer and use it in GitHub Desktop.
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