Edit This Code:
See Result »
<!DOCTYPE html> <html> <body> <p>Click the button to sort the array in descending order.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> var points = [40, 100, 1, 5, 25, 10]; document.getElementById("demo").innerHTML = points; function myFunction() { points.sort(function(a, b){return b-a}); document.getElementById("demo").innerHTML = points; } </script> </body> </html>
Result: