关于排序函数的返回值
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Array对象 </title>
<script type="text/javascript">
function sortNum(a,b) {
if(a>=b){
return 1
}
else{
return -1
}
}
var myarr = new Array("80","16","50","6","100","1");
document.write(myarr.sort(sortNum));
</script>
</head>
<body>
</body>
</html>
为什么我写的排序函数,最终没有按顺序排呢,是乱序
输出结果为:1,100,16,50,6,80