1.降序排列
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <body> <script type="text/javascript"> <!-- var arr=[1,5,5454,85,4,984,98,4,984,98,4,98]; function b(arr){ for (i=0;i<arr.length ;i++ ) { for (j=0;j<arr.length ;j++ ) { if (arr[i]>arr[j]) { var a=arr[i]; arr[i]=arr[j]; arr[j]=a } } } console.log(arr) } b(arr) //--> </script> </body> </html>