sort只能排序字符串,如果要排數字需要添加匿名函數作爲參數
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<script type="text/javascript">
var arr=[96, 8, 12, 72, 33, 118];
arr.sort(function (num1, num2){
return num1-num2;
});
alert(arr);
</script>
</head>
<body>
</body>
</html>