Sort three variables: Difference between revisions

Content added Content deleted
(Add source for Rust)
Line 2,103: Line 2,103:
bears, oh my!
bears, oh my!
lions, tigers, and</pre>
lions, tigers, and</pre>
=={{header|Red}}==
Red can natively sort values of various types. For instance here (not exhaustive): strings, integers, floats, characters, IP addresses, email addresses, words (~ variable names).
<lang Red>foreach [x y z] [
"lions, tigers, and"
"bears, oh my!"
{(from the "Wizard of OZ")}
77444 -12 0
3.1416 3.1415926 3.141592654
#"z" #"0" #"A"
216.239.36.21 172.67.134.114 127.0.0.1
john@doe.org max@min.com cool@bi.net
potato carrot cabbage
][
set [x y z] sort reduce [x y z]
print ["x:" mold x "y:" mold y "z:" mold z]
]</lang>
{{out}}
<pre>x: {(from the "Wizard of OZ")} y: "bears, oh my!" z: "lions, tigers, and"
x: -12 y: 0 z: 77444
x: 3.1415926 y: 3.141592654 z: 3.1416
x: #"0" y: #"A" z: #"z"
x: 127.0.0.1 y: 172.67.134.114 z: 216.239.36.21
x: cool@bi.net y: john@doe.org z: max@min.com
x: cabbage y: carrot z: potato</pre>


=={{header|REXX}}==
=={{header|REXX}}==