<html>
<head>
</head>
<body onLoad="clickOpen()">
<script type="text/javascript">
//比较函数
function compareInt(vNum1,vNum2)
{
var iNum1=parseInt(vNum1);
var iNum2=parseInt(vNum2);
if(iNum1<iNum2)
{
return -1;
}
else if(iNum1>iNum2)
{
return 1;
}
else
{
return 0;
}
}
function clickOpen()
{
var arr=[3,32,2,5];
arr.sort(compareInt);
alert(arr.toString());
}
</script>
</body>
</html>
评论