给数组排序方法2
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>json</title> <script type="text/javascript"> var sz=[12,3,65,4,89,8,32,1,26,57]; function zuixiaoxiabiao(arry,num){ var zuixiaoshu=arry[num]; var zuixiaoIndex=num; for(var i=num+1;i<arry.length;i++){ if(arry[i]<zuixiaoshu){ zuixiaoshu=arry[i]; zuixiaoIndex=i; } } return zuixiaoIndex; } for(var i=0;i<sz.length;i++){ var b=zuixiaoxiabiao(sz,i); var s; s=sz[i]; sz[i]=sz[b]; sz[b]=s; } alert(sz); </script> </head> <body> </body> </html>
衣带渐宽终不悔,为伊消得人憔悴,憔悴半天也没用,还是努力起来人富贵
posted on 2015-06-09 17:57 zhangjingyun 阅读(154) 评论(0) 编辑 收藏 举报