js数组排序,非常简单一个功能,分享给大家学习。
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <title> New Document </title>
- <meta name="Generator" content="EditPlus">
- <meta name="Author" content="">
- <meta name="Keywords" content="">
- <meta name="Description" content="">
- <script type="text/javascript">
- <!--
- function a(a,b){
- return a-b;
- }
- var test=[1,2,100,30,25];
- test.sort(a);
- for(var i=0;i<test.length;i++){
- document.write(test[i]+",");
- }
-
- </script>
- </head>
-
- <body>
-
- </body>
- </html>
|