Javascript examples for Array:sort
Get the top ten vars with the highest value using array sort() and reverse()
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w .j a v a 2 s .c om*/ var myarray=["t14", "t53", "t1","t87","t34","t32","t27","t23","t54","t12","t53","t98"]; myarray.sort(); myarray.reverse(); var final = myarray.slice(0,10); console.log(final); } </script> </head> <body> </body> </html>