Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>Click the button to sort the array in ascending 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 a>b});
    document.getElementById("demo").innerHTML = points;
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy