文字数组 - sort()

使用 sort() 方法从字面上对数组进行排序。

 

编辑您的代码:

<html>

<body>

<script type="text/javascript">

var arr = new Array(6)

arr[0] = "George"

arr[1] = "John"

arr[2] = "Thomas"

arr[3] = "James"

arr[4] = "Adrew"

arr[5] = "Martin"

document.write(arr + "<br />")

document.write(arr.sort())

</script>

</body>

</html>

 

查看结果:

     George,John,Thomas,James,Adrew,Martin
     Adrew,George,James,John,Martin,Thomas

 

posted @ 2015-01-13 17:35  紫发少年  阅读(327)  评论(0编辑  收藏  举报