Sort a string array : Sort : Array JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Array » Sort »

 

Sort a string array

















<html>
<head>
<title>Using the sort() method</title>
<script type="text/javascript" language="javascript">
<!-- //
function SortElements(){
var colors = new Array("red","blue","green");

colors.sort();

var cj = colors.join(", ");

alert("The sorted array contains: " + cj);
}
// -->
</script>
</head>
<body onload="SortElements()">

</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Array
» Sort