Solo pon el código en menos tonterías:
<Body> <Viv> sort () Ordena la matriz, no abre una nueva memoria y reemplaza los elementos de matriz originales </div> <div ID = "showBox"> 1. Array simple SILLO simple <script type = "text/javaScript"> var arreMple = new Array (1,8,7,6); Arrsimple.sort (); document.writeln (arrsimple.Join ()); </script> </div> <div> 2. Simple Array Custom Sort <script type = "text/javaScript"> var arreRSimple2 = new Array (1,8,7,6); arrsimple2.sort (función (a, b) {return ba}); document.writeln (arrsimple2.join ()); </script> Explicación: A, B representa dos elementos en la matriz, si return> 0 b antes de a; reutrn <0 a antes de b; Cuando A = B, la compatibilidad del navegador se simplifica: la salida AB se clasifica de pequeña a grande, y la salida BA se clasifica de gran a pequeña. </div> <div> 3. Simple Lista de objetos Clasificación de atributos personalizados <script type = "text/javaScript"> var objectList = new Array (); function persion (nombre, edad) {this.name = name; this.age = edad; } ObjectList.push (New Persion ('Jack', 20)); ObjectList.push (New Persion ('Tony', 25)); ObjectList.push (New Persion ('Stone', 26)); ObjectList.push (nueva persion ('Mandy', 23)); // clasificar objectList.sort (function (a, b) {return a.age-b.age}); for (var i = 0; i <objectList.length; i ++) {document.writeLn ('<Br />age:'+ObjectList[ifont>.age+' Nombre: '+ObjectList [i] .name); } </script> </div> <div> 4. Amable de atributos editables por simple lista de objetos <script type = "text/javaScript"> var objectList2 = new Array (); function workmate (nombre, edad) {this.name = name; var _age = edad; this.age = function () {if (! ObjectList2.push (New Workmate ('Tony', 25)); ObjectList2.push (New Workmate ('Stone', 26)); ObjectList2.push (New Workmate ('Mandy', 23)); // Ordenar por edad de la infancia a la lista de objetos grandes2.sort (función (a, b) {return a.age ()-b.age ();}); for (var i = 0; i <objectList2.length; i ++) {document.writeLn ('<Br />age:'+ObjectList2[ifont>.age()+' Nombre: '+ObjectList2 [i] .name); } </script> </div> </body>La comprensión en profundidad del artículo anterior del tipo de matriz JS es todo el contenido que comparto con ustedes. Espero que pueda darle una referencia y espero que pueda apoyar más a Wulin.com.