Anonymous user
Sort three variables: Difference between revisions
Add Jsish
No edit summary |
(Add Jsish) |
||
Line 1,149:
"z": 77444
}</pre>
=={{header|Jsish}}==
<lang javascript>#!/usr/bin/env jsish
/* Sort three variables, in Jsish. semi-colon start/end for unit test echo */
var x = 'lions, tigers, and';
var y = 'bears, oh my!';
var z = '(from the "Wizard of OZ")';
var arr = [x,y,z];
arr = arr.sort();
;'As strings, before:';
;x;
;y;
;z;
x = arr.shift();
y = arr.shift();
z = arr.shift();
;'x,y,z after:';
;x;
;y;
;z;
x = 77444;
y = -12;
z = 0;
arr = [x,y,z];
arr = arr.sort();
;'As numbers before:';
;x;
;y;
;z;
x = arr.shift();
y = arr.shift();
z = arr.shift();
;'x,y,z after:';
;x;
;y;
;z;
/*
=!EXPECTSTART!=
'As strings, before:'
x ==> lions, tigers, and
y ==> bears, oh my!
z ==> (from the "Wizard of OZ")
'x,y,z after:'
x ==> (from the "Wizard of OZ")
y ==> bears, oh my!
z ==> lions, tigers, and
'As numbers before:'
x ==> 77444
y ==> -12
z ==> 0
'x,y,z after:'
x ==> -12
y ==> 0
z ==> 77444
=!EXPECTEND!=
*/</lang>
{{out}}
<pre>prompt$ jsish --U sortThree.jsi
'As strings, before:'
x ==> lions, tigers, and
y ==> bears, oh my!
z ==> (from the "Wizard of OZ")
'x,y,z after:'
x ==> (from the "Wizard of OZ")
y ==> bears, oh my!
z ==> lions, tigers, and
'As numbers before:'
x ==> 77444
y ==> -12
z ==> 0
'x,y,z after:'
x ==> -12
y ==> 0
z ==> 77444
prompt$ jsish -u sortThree.jsi
[PASS] sortThree.jsi</pre>
=={{header|Julia}}==
|