<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
</style>
<script>
var arr=['c','d','a','e'];
//字符排序
//arr.sort();
//78会分开, 分别7和9对比8和9对比
/*var arr2=[4,3,5,6,78,9,0];
arr2.sort(function(a,b){
return a-b;
});
alert(arr2);
//字母文字排序
var arrWidth=['345px','23px','10px','1000px'];
arrWidth.sort(function(a,b){
return parseInt(a)-parseInt(b);
})
alert(arrWidth);*/
//随机数
var arr=[1,2,3,4,5,6,7,8];
arr.sort(function(a,b){
return Math.random()-0.5;
});
alert(arr);
</script>
</head>
<body>
</body>
</html>