sort ,我用的不对吗? 为什么不能降序输出?
<script type="text/javascript">
function sortNum(a,b) {
if(a>b)
var c=b;
else if(a<b)
c=a;
else
;
return c;
}
var myarr = new Array("80","16","50","6","100","1");
document.write(myarr.sort(sortNum));
</script>
<script type="text/javascript">
function sortNum(a,b) {
if(a>b)
var c=b;
else if(a<b)
c=a;
else
;
return c;
}
var myarr = new Array("80","16","50","6","100","1");
document.write(myarr.sort(sortNum));
</script>
2016-05-01
举报