Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Sorting array in Javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 103
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: