Using the sort() method on numbers and strings : Sort : Array JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Array » Sort »

 

Using the sort() method on numbers and strings

















<html>
<head>
<title>Using the sort() method on numbers and strings</title>
<script type="text/javascript" language="javascript">
<!-- //
function SortElements() {

    var myNums = new Array(9,4,"B",11,301);
    myNums.sort();

    var mj = myNums.join(", ");
    alert("The sorted array contains: " + mj);

}
// -->
</script>
</head>
<body onload="SortElements()">

</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Array
» Sort