RosettaCodeData/Task/Sort-three-variables/Jsish/sort-three-variables.jsish

89 lines
1.1 KiB
Plaintext

#!/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;
;'Mixed, integer, float, string';
x = 3.14159;
y = 2;
z = '1 string';
;x;
;y;
;z;
arr = [x,y,z].sort();
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
'Mixed, integer, float, string'
x ==> 3.14159
y ==> 2
z ==> 1 string
'x,y,z after:'
x ==> 2
y ==> 3.14159
z ==> 1 string
=!EXPECTEND!=
*/