【実行画面】
<script type="text/javascript">
<!--
color = new Array("red", "white", "black", "green", "blue", "yellow");
document.write(color + "<br>");
color.sort();
document.write(color + "<br>");
document.write(color.reverse() + "<br>");
// -->
</script>
|
<script type="text/javascript">
<!--
num = new Array(56, 9, 789, 1234);
num.sort();
document.write(num + "<br>");
num.sort(function(a,b){ return a-b; } );
document.write(num + "<br>");
// -->
</script>
|
num.sort(function(a,b){ return a-b; } );
|
<script type="text/javascript">
<!--
str = "5,13,4,9,21";
num = str.split(',');
document.write(num + "<br>");
num.sort(function(a,b){ return a-b; } );
document.write(num + "<br>");
// -->
</script>
|
num = str.split(',');
document.write(num + "<br>");
|
![]()