Anonymous user
Sort three variables: Difference between revisions
→{{header|Jsish}}, add mixed type sort
(Add Jsish) |
|||
Line 1,195:
;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;
/*
Line 1,214 ⟶ 1,229:
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!=
*/</lang>
{{out}}
<pre>prompt$ jsish --U sortThree.jsi
'As strings, before:'
x ==> lions, tigers, and
Line 1,235 ⟶ 1,258:
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
prompt$ jsish -u sortThree.jsi
|