Sort three variables: Difference between revisions

Add Swift
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(Add Swift)
Line 2,299:
0
77444</pre>
 
=={{header|Swift}}==
 
<lang swift>func varSort<T: Comparable>(_ x: inout T, _ y: inout T, _ z: inout T) {
let res = [x, y, z].sorted()
 
x = res[0]
y = res[1]
z = res[2]
}
 
var x = "lions, tigers, and"
var y = "bears, oh my!"
var z = "(from the \"Wizard of OZ\")"
 
print("Before:")
print("x = \(x)")
print("y = \(y)")
print("z = \(z)")
print()
 
varSort(&x, &y, &z)
 
print("After:")
print("x = \(x)")
print("y = \(y)")
print("z = \(z)")</lang>
 
{{out}}
 
<pre>Before:
x = lions, tigers, and
y = bears, oh my!
z = (from the "Wizard of OZ")
 
After:
x = (from the "Wizard of OZ")
y = bears, oh my!
z = lions, tigers, and</pre>
 
=={{header|Tcl}}==