Sorting is the process of arranging elements systematically either ascending or descending order.
The main purpose of sorting information is to optimise its usefulness for specific tasks.
Sorting arranges data in a sequence by which searching becomes easier
<p>Click the button to get the result of sorted array.</p>
<button onclick="myFunction()">result</button>
<p id="samp"></p>
<script>
var n = ["Pranav", "Ayush", "Mukesh", "Ravi","Pankaj" ];
document.getElementById("samp").innerHTML = n;
function myFunction() {
n.sort();
document.getElementById("samp").innerHTML = n;
}
</script>
</body>
</html>
0 Comment(s)