Use default sort() method to sort an array
<html>
<head>
<title>Array literal</title>
<script type="text/javascript" >
var planets = ['a', 'v', 'asdf', 'fdsa', 'a'];
planets.sort();
document.write(planets);
</script>
</head>
<body>
</body>
</html>
Related examples in the same category