js中的sort函数的自定义函数

来源:互联网 发布:自学人工智能 编辑:程序博客网 时间:2024/06/04 18:15
<!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) {        return b-a   }var myarr = new Array("80","16","50","6","100","1");document.write(myarr.sort(sortNum));</script></head><body></body></html>
0 0