Sort three variables: Difference between revisions

m
→‎{{header|REXX}}: undid someone's older change, added/changed whitespace.
No edit summary
m (→‎{{header|REXX}}: undid someone's older change, added/changed whitespace.)
Line 2,055:
say '───── original value of Y: ' y
say '───── original value of Z: ' z
if x>y then do; _= x; x= y; y= _; end end /*swap the values of X and Y. */ /* ◄─── sorting.*/
if y>z then do; _= y; y= z; z= _; end end /* " " " " Y " Z. */ /* ◄─── sorting.*/
if x>y then do; _= x; x= y; y= _; end end /* " " " " X " Y. */ /* ◄─── sorting */
say /*stick a fork in it, we're all done. */
say '═════ sorted value of X: ' x
Line 2,063:
say '═════ sorted value of Z: ' z</lang>
{{out|output|text=when using the default inputs:}}
<pre>
<pre>───── original value of X: lions, tigers, and
───── original value of Y: bears, oh my!
───── original value of Z: (from "The Wizard of Oz")
Line 2,069 ⟶ 2,070:
═════ sorted value of X: (from "The Wizard of Oz")
═════ sorted value of Y: bears, oh my!
═════ sorted value of Z: lions, tigers, and</pre>
</pre>
 
===numeric only===
Line 2,081 ⟶ 2,083:
if y=='' | y=="," then y= -12 /* " " " " " " */
if z=='' | z=="," then z= 0 /* " " " " " " */
w= max( length(x), length(y), length(z) ) + 5 /*find max width of the values, plus 5.*/
say '───── original values of X, Y, and Z: ' right(x, w) right(y, w) right(z, w)
low = x /*assign a temporary variable. */ /* ◄─── sorting.*/
mid = y /* " " " " */ /* ◄─── sorting.*/
high= z /* " " " " */ /* ◄─── sorting.*/
x= min(low, mid, high) /*determine the lowest value of X,Y,Z. */ /* ◄─── sorting.*/
z= max(low, mid, high) /* " " highest " " " " " */ /* ◄─── sorting.*/
y= low + mid + high - x - z /* " " middle " " " " " */ /* ◄─── sorting.*/
/*stick a fork in it, we're all done. */
say '═════ sorted values of X, Y, and Z: ' right(x, w) right(y, w) right(z, w)</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
<pre>───── original values of X, Y, and Z: 77444 -12 0
═════ sorted───── original values of X, Y, and Z: 77444 -12 -12 0 77444</pre>0
<pre>─────═════ sorted original values of X, Y, and Z: 77444 -12 -12 0 077444
</pre>
 
=={{header|Ring}}==