<button onclick="sortArray()">Sort Array</button>
<p id="demo"></p>
<script>
var courses = ["javascript", "php", "angularjs", "node js"];
document.getElementById("demo").innerHTML = courses;
function sortArray() {
courses.sort();
document.getElementById("demo").innerHTML = courses;
}
</script>